Jquery css compare background-colour value
<p>I have an <code>img</code>. On click it checks the background color of its parent and toggles the background color to grey if it is white and to white if it is grey.   here k have value that is rgb(255,255,255) (white) but the if loop sud be excuted but else part executed... means if is not working...   here in my code what happens when i execute it .... it only exectes only if part sometimes and when i change something it only exectes else part .... even if condition do not satisfy... like it should make grey when white and white when it is grey... but it did not.... i want to ask the condition which i have used ... is it correct...</p>

<pre><code>function havetotha(it) {
    var k = $(it).parent().css('background-color');
    $('#message').html(k);
    if (k == 'white') {
        $(it).parent().css('backgroundcolor','grey');
    }
    else {
        $(it).parent().css('backgroundcolor','white');
    }
}
</code></pre>

<p>i figured it out ...</p>

<p>in if in condition i was comparing ($(it).parent().css('background-color')=="rgb(255,255,255)").... where rgb(255,255,255) is string but $(it).parent().css('background-color') it is not string so.... i used a trick i made two divs one with grey backgroun and other with white.... and compared there background with the my elements .... it works just take very long time to get into my mind..</p>
