Fiddle : http://jsfiddle.net/y790z6zq/
I want to make a case insensitive search based on data attributes using find method of jquery.
Here is the HTML :
<body>
<div class="main">
<div>
<p data-Col="MyVal"> hkjhkjh</p>
</div>
<div data-Col="MyVAl"> some more text
</div>
</div>
<div class="main">
<div data-Col="myval"> some more text
</div>
<div >
<p data-Col="myval"> some more nesting</p>
</div>
</div>
</body>
& the script:
var searchValue ="myval";
$(".main").find("[data-Col='" + searchValue + "']").css("background-color","red");
I could set color to the last div (where case matches) but others are not getting selected.
Please Help.. Thanks in advance..
Edit : I also tried below script but it did not work..
$(".main").filter(function() {
return this.data("Col").toLowerCase() == searchValue.toLowerCase();
}).css("background-color","red");