I've got to be missing something really simple here. All I want to do is make the color of all list items with a class of "link" toggle between blue and black. I've read through half a dozen posts and haven't figured out an answer yet.
jfiddle: http://jsfiddle.net/Y8K2x/1/
HTML:
<button>Toggle Link Color</button>
<ul>
<li class="item">Item 1</li>
<li class="link">Link 2</li>
<li class="item">Item 3</li>
<li class="link">Link 4</li>
<li class="link">Link 5</li>
<li class="item">Item 6</li>
<li class="link">Link 7</li>
<li class="item">Item 8</li>
</ul>
Here's the JS:
$('button').click(function () {
var linkColor = $('.link').css('color');
if (linkColor == '#0099ff') {
$('.link').css('color', '#000000');
} else if (linkColor == '#000000') {
$('.link').css('color', '#0099ff');
}
});