How to say with variables: If this id matches this class don't do this
<p>In words, I want to say, If the body Id is not equal to a list item's class execute the following function, I have tried to get the code right but nothing seems to work.</p>

<p>I have 4 pages each with an ID to make the active state work in a css sprite that work great. On top of that I added between normal and hover a jquery opacity effect but the problem is that when I hover the active state It also changes to hover and I want the active sprite to stay put when hover, anyhelp would be appreciated, Saludos.</p>

<p>Html: </p>

<pre><code>&lt;ul id="nav"&gt;
    &lt;li class="home"&gt;&lt;a href="index.html" title="Home Page"&gt;Home&lt;/a&gt;&lt;/li&gt;
    &lt;li class="portfolio"&gt;&lt;a href="portfolio.html" title="Portfolio Page"&gt;Portfolio&lt;/a&gt;&lt;/li&gt;
    &lt;li class="contact"&gt;&lt;a href="contact.html" title="Contact Form Page"&gt;Contact&lt;/a&gt;&lt;/li&gt;
    &lt;li class="about"&gt;&lt;a href="about.html" title="About me Page"&gt;About me&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
</code></pre>

<p>Jquery:</p>

<pre><code>  $(document).ready(function(){

    // Get the ID of the body
    var parentID = $("body").attr("id");

    // Loop through the nav list items
        $("#nav li").each(function() {

        // compare IDs of the body and class of list-items
           var myClass = $(this).attr("class");

        // only perform the change on hover if the IDs don't match (so the active link doesn't change on hover)
        if (myClass != "n-" + parentID) {

   // Opacity effect between states 
    $('ul#nav li a').removeClass('hover');  
    $("ul#nav li a").wrapInner("&lt;span&gt;&lt;/span&gt;");
    $("ul#nav li a span").css({"opacity" : 0});
    $("ul#nav li a").hover(function(){
        $(this).children("span").stop().animate({"opacity" : 1}, 500);
    }, function(){
        $(this).children("span").stop().animate({"opacity" : 0}, 500);
        });
      }

     });

});
</code></pre>
