jquery:如何选择隐藏字段?
我正在使用 jquery.raty 脚本,它会在我的页面中写入一个隐藏字段,例如:
<input id="cancel-score" type="hidden" name="news_question_1" value="1">
我有这个和许多其他表单元素,我想监视 onChange。
我这样做的是:
$('#NewsletterSurveyForm').find(':input').each(function(){
$(this).change(function(){....
它适用于所有元素,但不适用于隐藏元素。
有谁知道如何获得它的价值?
I am using the jquery.raty script which does write a hidden field into my page like:
<input id="cancel-score" type="hidden" name="news_question_1" value="1">
I have this and many other form elements which I would like to monitor onChange.
I do this with:
$('#NewsletterSurveyForm').find(':input').each(function(){
$(this).change(function(){....
Which works for all elements, but just not the hidden one.
Does anyone has an idea how to get its value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下代码,
但以编程方式更改值时不会触发更改事件。所以当值改变时你必须手动触发它。
you can use following code,
but change event doesn't fire when the value is programmatically changed. so you have to trigger it manually when the value changes.
我认为隐藏输入不支持更改事件。
请参阅这个问题
我想你应该解决这个变化触发更高的水平。
I don't think the hidden input supports the change event.
See this question
I think you should address this change trigger a level higher up.