I have a HTML likes this
<ul id="changeColr">
<li>100</li>
<li>200</li>
<li>300</li>
</ul>
<button>Click Me</button>
if a li contains a value of 200, I want to use JQuery to change the color of 200 to red.
Here is my JQuery
$(document).ready(function() {
$('button').click(function() {
if ($('#changeColr li').attr('200')) {
$(this).css('color', 'red');
} else {
$(this).css('color', '')
}
});
});
But it doesn't work out. Please give me a hand. Thanks
if( $('#changeColr li').attr('200'))changed withif( $('#changeColr li').text('200'))