Find Id Of Clicked Button
I wanted to get the id of clicked button since i have 4-5 buttons on my form.
Fiddle Demo
Problem
Fiddle Demo
Problem
$("input")
--> selects elements with tag input
eg. <input type="text"/>
but not <button>
tag .
Solution 2:
I'd try to replace this
with the event triggerer.
var urlid = $(event.target).attr("id");
Also, probably your onclick
function is preventing your script to be executed, because it's handling the click event, not letting your function do it.
Solution 3:
I ditched the onclick
attributes of buttons you have, and hooked click events to button
rather than input
, and it worked. So check whether you are connecting to the right element.
See example here.
Solution 4:
<script>
jQuery(":button").click(function (event) {
var urlid = $(this).attr('id')
alert(urlid);
})
</script>
Try this its work
Solution 5:
very simply:
$("input").click(function (event) {
var urlid = this.id;
alert(urlid);
})
for button:
$("button").click(function (event) {
var urlid = this.id;
alert(urlid);
})
Post a Comment for "Find Id Of Clicked Button"