When I click on a Select option, I am handling the Changed event.
I want to simulate this in code, and have it LOOK THE SAME as when the user clicks on the option.
So far, setting 'selected' attribute on the option does not highlight it the same as when you click on it.
I can trigger 'change' on the option and hit my handler, but the option on the list is not selected as if clicked.
Suggestions?
UPDATE: The query selection code works just fine - thanks for the responses. The problem was mine (of course). I had the selection code outside the Jquery.Ajax Success: block, so I think it was working, but the ajax response code was hosing it.
$('option[value="4"]').attr('selected', 'selected').parent().focus();
Works for me. See http://jsfiddle.net/TZVyh/1/
I was working with the jquery datatable plugin ColumnFilterWidgets and I needed to do the following to execute the filter action (based on answers from elclanrs and Ben Foster):
$("option").attr('selected', 'selected').parent().focus();
$("option").parent().change();
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