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
Post a Comment