[转]jQuery: how to get which button was clicked upon form submission?
$(document).ready(function() {
$("form").submit(function() {
var val = $("input[type=submit][clicked=true]").val();
// DO WORK
});
$("form input[type=submit]").click(function() {
$("input[type=submit]", $(this).parents("form")).removeAttr("clicked");
$(this).attr("clicked", "true");
});
});
$("form").submit(function() {
// Print the value of the button that was clicked
console.log($(document.activeElement).val());
}
This was helpful, to get the id of the activeElement, I did $(document.activeElement).attr('id');
|
|
|
posted on 2016-03-10 16:14 freeliver54 阅读(273) 评论(0) 收藏 举报
浙公网安备 33010602011771号
document.activeElement.id