Trigger change event of dropdown using jQuery

With jQuery you can easily update the value of a select dropdown box, but this won't automatically trigger the 'change' event in the same way it would if you selected it manually. This code-snippet will change the value, and then trigger the event to run any associated code:


<select id='languages'>
    <option value='css'>CSS</option>
    <option value='html'>HTML</option>
    <option value='js'>Javascript</option>


Update the the select element by value and then use the 'trigger' method to call the change event:


Sign Up
comments powered by Disqus

Popular Tags

Need a web developer?

If you'd like to work with code synthesis on your next project get in touch via the contact page.