Home jQuery - setting the selected value of a select control via its text description
Reply: 0

jQuery - setting the selected value of a select control via its text description

user594
1#
user594 Published in May 28, 2018, 5:06 am

I have a select control, and in a javascript variable I have a text string.

Using jQuery I want to set the selected element of the select control to be the item with the text description I have (as opposed to the value, which I don't have).

I know setting it by value is pretty trivial. e.g.

$("#my-select").val(myVal);

But I'm a bit stumped on doing it via the text description. I guess there must be a way of getting the value out from the text description, but my brain is too Friday afternoon-ed to be able to work it out.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.42413 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO