I'm using the Jquery Chosen plugin on a select box, however I'd like to focus this on page load. I've used the following code to focus a text input:
onLoad="document.forms.sales_order_form.customer.focus()"
But this doesn't work for the select box:
<select data-placeholder="Select a Customer..." class="chzn-select" name="customer" style="width:400px;">
<option value=""></option>
</select>
In Chosen 1.0, this command is now:
$('.my_select_box').trigger('chosen:activate');
See here.
If your using the first example (standard select box) you can use:
jQuery(document).ready(function($) {
$('.chzn-drop .chzn-search input[type="text"]').focus();
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With