如何使用JQuery获取特定表单字段值 [英] How to get the Specific Form Field value using JQuery
本文介绍了如何使用JQuery获取特定表单字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张表格
<form id="post_comment" action="cmt.php" method="post">
<input type="hidden" name="type" value="sub" />
<textarea id="body"></textarea>
</form>
我正在使用此代码访问表单
I am accessing the form using this code
$("#post_comment").submit(function(event){
var form = $(this);
});
如何获得的值< input type =hidden name =typevalue =sub/>
来自此表单。
我试图使用 form.input(type)
但它无效。
How can I get the value of <input type="hidden" name="type" value="sub" />
from this form.
I tried to get using form.input("type")
but it is not working.
推荐答案
$("#post_comment").submit(function(event){
var inputValue = $("input[name='type']",this).val();
});
这篇关于如何使用JQuery获取特定表单字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文