我的网页上有2个div。我需要的是按下提交按钮时只提交form_div。
<div id="main">
<div id="form_div">
<form name="form">
<input type="submit" name="save" id="save"/>
</form>
</div>
<div id="other_div"></div>
</div>`
答案 0 :(得分:0)
在jquery中,
你可以打电话
$("your-custom-selector").click(function(){
//Do-whatever. This code only runs when your customselector is pressed.
});
在JavaScript中
document.getElementById("your-custom-selector").addEventListener("click", myFunction);
function myFunction() {
//Do-whatever. This code only runs when your customselector is pressed.
}