I have numerous buttons on my page with the same class names. However these buttons have different ID's. How do i do this:
$(".vote").click(function(){
var id = $(this).{ID OF CLICKED BUTTON};
});
How can i make this pseudo code work?
Thanks
Use this code
M sure you never face any problem with this solution in any situation.
With jQuery object (not necessary)
Without jQuery object (faster)
You might want to look into this:
The ID is accessible directly from the element. There's absolutely no need to use a jQuery method.
Using attr:
.attr allows you to get html tag attributes by name.
You could use