i have these two buttons and i want one of them to be disabled when the other was clicked.
There is html
<button type="submit" id="button_user" name="submit" class="btn btn-small btn-primary" data-toggle="collapse" data-target="#fsearch">Pretraga terena na sajtu</button>
<button type="submit" id="button_field" name="submit" class="btn btn-small btn-primary" data-toggle="collapse" data-target="#usearch">Pretraga korisnika na sajtu</button>
I have managed to do this with two functions and onclick, but i would like to know is there any elegant way to do this in one function so that inline js can be avoided?
this is my js:
$(document).ready(function(){
disable_one = function(){
if($('button_user').data('clicked', true)){
$('#button_field').attr("disabled", "disabled");
return;
}
};
disable_two = function(){
if($('button_field').data('clicked', true)){
$('#button_user').attr("disabled", "disabled");
return;
}
};
});