Jquery selector returning html element
<p>I am trying to iterate through a collection of  elements, trying to locate a specific element and apply a class to that element. The problem is that, even though the selector returns a collection of objects, and does enter the conditional that applies the class, when looking at the source the class is not applied.</p>

<p>This is the function:</p>

<pre><code>function HighlightNav() {

$('.quick-launch-nav').css('visibility', 'visible');
var navitems = $('a.topnav-item[href]');
$(navitems).each(function () {
    var item = this;
    var linkUrl = item.href;
    var webUrl = IPC_siteUrl + IPC_webUrl;

    if (webUrl.match('^' + linkUrl)) {
        $(item).addClass('topnavselected');
        var parent = $(item).parent('.topnav-item');
        $(parent).addClass('topnavselected');
    }
});
}
</code></pre>

<p>When I try to debug it by looking at the inner html, it returns a javascript function and not what I expected.</p>

<p>Am I doing something wrong here?</p>

<p>Here is the markup. FYI its SharePoint so its ugly.</p>

<pre><code>&lt;td onmouseover="Menu_HoverStatic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="zz1_TopNavigationMenun0"&gt;
    &lt;table class="topnav-item zz1_TopNavigationMenu_4" cellpadding="0" cellspacing="0" border="0" width="100%"&gt;
        &lt;tr&gt;
            &lt;td style="white-space:nowrap;"&gt;
                &lt;a class="zz1_TopNavigationMenu_1 topnav-item zz1_TopNavigationMenu_3"
                 href="http://webapp/en/about" 
                 accesskey="1" style="border-style:none;font-size:1em;"&gt;About&lt;/a&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/td&gt;
</code></pre>

<p>And when I try to do $(item).html.toString() this is what I get:</p>

<pre><code>function(a){return f.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(W,""):null;if(typeof a=="string"&amp;&amp;!ba.test(a)&amp;&amp;(f.support.leadingWhitespace||!X.test(a))&amp;&amp;!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"&lt;$1&gt;&lt;/$2&gt;");try{for(;d&lt;e;d++)c=this[d]||{},c.nodeType===1&amp;&amp;(f.cleanData(c.getElementsByTagName("*")),c.innerHTML=a);c=0}catch(g){}}c&amp;&amp;this.empty().append(a)},null,a,arguments.length)}"
</code></pre>
