99
rated 0 times
[
104]
[
5]
/ answers: 1 / hits: 156998
/ 9 Years ago, tue, september 29, 2015, 12:00:00
I have multiple buttons containing different values.
My buttons :-
<button id=1 name=1 value=1>Button1</button>
<button id=2 name=2 value=2>Button2</button>
Now, if I click on Button1, I should get it's value. That is 1, and if I click Button2, I should get value 2.
I have written this code :-
<script type=text/javascript>
$(button).click(function() {
var fired_button = $(button).val();
alert(fired_button);
});
</script>
But it always alerts 1. What must I do to fix my code?
More From » jquery