Handy script, whenever you click an element with a class called .button it will alert the name and value of that element.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<script> $(document).ready(function(){ $(".button").click(function() { var dog = $(this).attr("value"); alert(dog); var cat = $(this).attr("name"); alert(cat); var fish = $(this).attr('id'); alert(fish); var myClass = $(this).attr("class"); alert(myClass); }) }); </script> |
Or try this
1 2 3 |
var emailaddress = $('.changeme').text(); |
You could even swap the button text when you click by using this method.
Last resort!
1 2 3 4 |
var clickedon = $(this).children('.tablebutton').attr('value'); alert (clickedon); |
Take a look at this also Get the id, value,name,html of element after click function