-1

I have a searchable dropdown and i want to select the option value which i am passing using this query:

$(#id).val('optiontext').attr('selected',true),

but every time it is typing in search text box inside dropdown, but ineed to select that option value.

AdityaK
  • 329
  • 1
  • 4
  • 18

1 Answers1

0

apart from missing quotes in id selector, you need to select option by text:

$("#id option").filter(function() {
  return this.text == 'optiontext'; 
}).attr('selected', true);​
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125