jquery - How to use text of option to find value of the same -


i have multiple select option id name test , has 1 option b.

$('#test').find('option[text="b"]').val();

here if use getting correct result i.e. value of option. problem in jquery don't have b instead of have variable has value b.please tell me guys how can use variable in place of b in jquery.

i tried using this

var x=myvariable

$('#test').find('option[text=x]').val();

thanks

you can concatenate variables this, try:

$('#test').find('option[text="'+x+'"]').val() 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -