我有一个表格,需要在所有按钮按下时或每当用户离开页面时提交,是否可能如此?
答案 0 :(得分:0)
使用jquery检测用户是否离开页面。 https://api.jquery.com/unload/
$( window ).unload(function() {
//call your function here that executes the form
return "Handler for .unload() called.";
});
使用jquery检测按钮按下。
$(document).on('click', '.buttonCLass', function(){
//code here
})