I hope this isn't a duplicate because I have not seen anything that I could reference anything from but, I want to focus on the select which is just:
$("#idHere").focus();
I have read that you cannot select the options doing so but I was wondering if maybe you could trigger()
the spacebar
key once the select
has been focused on?
My attempt at this was:
$('body').on('click', '#sid', function () {
$("#size").attr("size", $("#size").attr("expandto")).css('z-index', 2);
$("#size").focus().select();
e = jQuery.Event("keydown");
fake = $.extend({}, e, { which: 32, ctrlkey: true });
$("#size").trigger(fake);
});
Is this possible? But this does not work. Reference to idea: here.
Edit: The reason I want to try trigger the spacebar
key is because it actually acts like the enter key (or a click).
Edit to make more sense: I want to focus()
on the <select>
and then trigger the spacebar
so the <select>
is opened to display the options - all this happens within a click
function. Is this possible?