how can i retrieve find out which button click is from which div.
Basically i have multiple div
<div id="rare1">
<input type=button value="OK" id=btn>
</div>
<div id="rare2">
<input type=button value="OK" id=btn>
</div>
<div id="rare3">
<input type=button value="OK" id=btn>
</div>
i have a function
$("#btn").click(function(){
$("#rare"+i+" #btn").attr("disabled", "true");
}
this way i can disable the latest button being added.
how can i select which ever button is click on different div id and select the correct btn to disable?
so sorry forget to add something i want to retrieve the div id that clicked the button too.
An
idmust be uniqe per element per page. Currently you havebtnfor each button, use a class instead egclass="btn"and then modify your code like this:JS:
To get current clicked button, use
$(this)as shown in code above.Update Based On Comments
To get parent div id, use:
So: