Reputation: 13
I have a problem i need a jquery code to find which anchor tag-edit has been clicked in my jquery code. actually there are list of edit buttons so i need to find the the id of that particular button.
Thanks in advance Nilanjan Saha
Upvotes: 0
Views: 71
Reputation: 31077
You can figure out which Id has been clicked in the jquery click event. let's say your buttons have a common class
<button id='one' type='button' class='my-edit-buttons'>button one</button>
<button id='two' type='button' class='my-edit-buttons'>button two</button>
<button id='thr' type='button' class='my-edit-buttons'>button thr</button>
you can bind a click event to all of those buttons with the following:
<script type='text/javascript'>
$('.my-edit-buttons').click(function(){
var buttonClicked = $(this);
var idOfButtonClicked = buttonClicked.attr('id');
alert(idOfButtonClicked);
});
</script>
You can test this solution here.
Upvotes: 1
Reputation: 7763
Try with $(this) on the event function, i.e:
$("something").click(function() {
var uid = $(this).attr('uid');
...
}
Upvotes: 0