I have a dropdown list, a textbox and a button. If I types a word in the textbox and click the button then the dropdown list should select the list item according to that word in the textbox.
For example: If I type 23 then the dropdown should lists the item starting 23.
@GG. is a better option using jQuery UI, but here is a very simple working model not using UI: http://jsfiddle.net/flackend/MA95K/2/
HTML:
jQuery:
Edit
Here is a new jsfiddle that uses jQuery UI’s autocomplete: http://jsfiddle.net/flackend/rPGUy/1/
Edit
$('option[selected="selected"]').removeAttr('selected');is basically saying, “find all option tags that have an attributeselectedwith the valueselected, if there are any, and remove that attribute.”So this, for example:
Would become this:
So now when we have jQuery select a new option tag it won’t conflict.