How To Detect Which Button Is Clicked Using Jquery
how to detect which button is clicked using jQuery
Copy
Solution 2:
$(function() {
$('input[type="button"]').click(function() { alert('You clicked button with ID:' + this.id); });
});
Solution 3:
Since the block is added dynamically you could try:
jQuery( document).delegate( "#dCalc input[type='button']", "click",
function(e){
var inputId = this.id;
console.log( inputId );
}
);
Solution 4:
jQuery can be bound to an individual input/button, or to all of the buttons in your form. Once a button is clicked, it will return the object of that button clicked. From there you can check attributes such as value...
$('#dCalc input[type="button"]').click(function(e) {
// 'this' Returns the button clicked:// <input id="btn1" type="button" value="Add">// You can bling this to get the jQuery object of the button clicked// e.g.: $(this).attr('id'); to get the ID: #btn1console.log(this);
// Returns the click event object of the button clicked.console.log(e);
});
Post a Comment for "How To Detect Which Button Is Clicked Using Jquery"