Trigger Click Event On A Dropdown List
I have 2 dropdown lists, the first one goes as follows :
Solution 1:
You need to dispatch onchange event:
functionchangeLang(someth) {
var nLang = someth.value,
evt = document.createEvent("HTMLEvents");
evt.initEvent("change", false, true);
$('.goog-te-combo').val(nLang)[0].dispatchEvent(evt);
}
Solution 2:
Does this help?
var$el = $(".goog-te-combo option[value=" + nLang + "]");
$el.prop('selected',true);
$el.trigger("click");
More on .trigger().
Solution 3:
I did the same thing other day. Simple solution since you are using jQuery:
<selectid="selectId"></select><scripttype="text/javascript">/*for an action event upon a change i did this*/
$('#first-dropdown-id').change(function(){
//your code/*nesting the click trigger function for it to get triggered*/
$('#widget-dropwdown-id').trigger( "click" );
}
});
</script>
Post a Comment for "Trigger Click Event On A Dropdown List"