jQuery doesn’t fire onChange event on hidden fields by default

Changes in value of hidden input elements don’t automatically fire the .change() event. So, whenever you set the value of any hidden input element & want the change to be tracked, you explicitly have to tell jQuery to trigger change event on that hidden input element.

function changeStatus(statusValue) {
$('#status').val(statusValue).trigger('change');
}

…. and then …

$('#status').change(function(){
... Perform some function on change of value ...
})
Unknown's avatar

Author: Makarand Thengdi

Director of Engineering, DevOps, and Releases at LeadSquared, with over a decade of experience in leading engineering and DevOps transformations for high-growth companies. Passionate about optimizing software delivery pipelines, cloud infrastructure, and security compliance. In this blog, I share my learnings and insights on DevOps, cloud technologies, and modern software engineering, reflecting my journey from code to cloud.

One thought on “jQuery doesn’t fire onChange event on hidden fields by default”

Have something to say ?

This site uses Akismet to reduce spam. Learn how your comment data is processed.