jquery: How can I select a hidden field?
12,370
Solution 1
you can use following code,
$("input[type='hidden']").change(function(){......});
but change event doesn't fire when the value is programmatically changed. so you have to trigger it manually when the value changes.
$("#hiddenId").val("new value").change();
Solution 2
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.
Author by
Admin
Updated on June 28, 2022Comments
-
Admin almost 2 years
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?