我有:
<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>
如果我有以下代码,如何获取点击按钮的ID:
$(".buttons").click(function(){
//alert("Clicked!");
//alert($('.buttons').closest('form').attr('id'));
})
答案 0 :(得分:2)
活动授权
$('.buttons').on('click', 'input[type=submit]', function(e) {
alert(this.id);
});