I have:
<div class="buttons">
<input id = "previous" class="previous_button" type="submit"
style="margin-right: 10px;" value="Previous"/>
<input id = "next" class="next_button" type="submit"
style="margin-right: 10px;" value="Next"/>
</div>
How can I get the id of the clicked button when I have the following code:
$(".buttons").click(function(){
//alert("Clicked!");
//alert($('.buttons').closest('form').attr('id'));
})
Event delegation
$('.buttons').on('click', 'input[type=submit]', function(e) {
alert(this.id);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.