Reputation: 171
is there a way to trigger a select2 item from the dropdown via jquery or javascript?
I managed to trigger the main select2 element with
$("#s2id_address a").trigger({type:'mousedown'});
in order to open the Dropdown.
Now i would like to trigger the first Element of the Dropdown, but none of my examples are working;
$("#select2-drop ul li[1]").click();
$("#select2-drop ul li[1]").trigger('click');
$("#select2-drop ul li[1]").trigger({type: 'mousedown'});
$("#select2-drop ul li[1]").trigger('change');
Upvotes: 2
Views: 1013
Reputation: 171
Found a working solution
$(".select2-results li:nth-child(LISTINDEX) div").trigger({type:'mouseup'});
does the trick
Upvotes: 2