I want to select options dynamically in a html select element by Jquery or JavaScript. Is there any way for this.So, as soon as i select it , it will select as well as trigger the onchange event handler.
Thanks in Advance.
I want to select options dynamically in a html select element by Jquery or JavaScript. Is there any way for this.So, as soon as i select it , it will select as well as trigger the onchange event handler.
Thanks in Advance.
You can set the value using .val("new value"), and trigger the jQuery event handlers for the change event via .change(), e.g.:
$("selector for the select box").val("new value").change();
.trigger('change'), but yes, that's just the long-hand way of writing .change().