[英]Using jQuery, how do I detect which <input type='image> was clicked in a form with multiple submit images?
Let's say we have this form: 假设我们有这种形式:
<form>
<input type="text" name="some_name" value="val" id="some_name">
<input type="image" value="action" alt="Add To Cart" name="add" src="/images/submit.gif">
<input type="image" value="action" alt="Shop some more" name="return" src="/continue_shopping.gif">
</form>
How do I find the input that submitted the form? 如何找到提交表单的输入?
You could add IDs to your different input items : 您可以将ID添加到不同的输入项中:
<input id="SomeName" type="text" name="some_name" value="val" id="some_name">
<input id="AddCart" type="image" value="action" alt="Add To Cart" name="add" src="/images/submit.gif">
<input id="Return" type="image" value="action" alt="Shop some more" name="return" src="/continue_shopping.gif" />
And then, in your jQuery, access the events with 然后,在您的jQuery中,使用
$("#Return").click(function(){
//do your stuff
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.