I have two div elements as below:
<div class="sc-info" tags="abc mno">
....
</div>
<div class="sc-info" tags="abc xyz">
....
</div>
I want perform hide() and show() based on value present in tags.Some thing like below
$('div.sc-info[tags with "abc"]').hide() // This should hide both divs
$('div.sc-info[tags with "xyz"]').show() //This should show only second one
Use the Attribute Contains Word Selector (
~=) selectorhttp://api.jquery.com/attribute-contains-word-selector/
Response to comment:
To select multiple words within those attributes you’ll have to filter on
div.sc.infofor both possible attribute selectors.Example: http://jsfiddle.net/hunter/AS6Zp/