jquery multiple selector with contains()

lovemeback

New Member
I've a lot of \[code\]<option>\[/code\]s in a \[code\]<select>\[/code\]and and extra attribute called \[code\]zip\[/code\]\[code\]<SELECT id="city"> <OPTION zip="AUC 1291 100005" value="http://stackoverflow.com/questions/15598667/1">City 1</OPTION> <OPTION zip=" 1295 100006" value="http://stackoverflow.com/questions/15598667/2">City 2</OPTION> <OPTION zip=" 1299 100008" value="http://stackoverflow.com/questions/15598667/3">City 3</OPTION></SELECT>\[/code\]Now I want to select the Option which Text or ZIP contains a string value, but the following code doens't work.\[code\]var val = '1291'; //Zip codevar x = $('#city option:contains('+val+'), #city zip:contains('+val+')').val();\[/code\]Why?
 
Back
Top