如何刷新提交按钮单击div?

时间:2016-01-19 08:54:41

标签: html

我的网页上有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>`

1 个答案:

答案 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.
}