jQuery Selector find equal something

Using jQuery each find something

<br />
&lt;script type=&quot;text/javascript&quot;&gt;</p>
<p>var searchItem = &quot;searchItem&quot;;<br />
var searchValue;<br />
$(&quot;select&quot;).find(&quot;option&quot;).each(function(n){<br />
    if($(this).val() == searchItem) {<br />
        searchValue = $(this).attr(&quot;data-searchvalue&quot;);<br />
    }<br />
});</p>
<p>&lt;/script&gt;<br />

Using jQuery selector attribute find something

<br />
&lt;script type=&quot;text/javascript&quot;&gt;</p>
<p>var searchItem = &quot;searchItem&quot;;<br />
var searchValue = $(&quot;select&quot;).find(&quot;option[value='&quot;+searchItem+&quot;']&quot;).attr(&quot;data-searchvalue&quot;);</p>
<p>&lt;/script&gt;<br />

Leave a Reply