If Statements Skipping or Evaluating Strangely, JavaScript and jquery
<p>So in jQuery, I have a global variable "currentSubNav" that stores a current visible element. The following code executes on "mouseenter".</p>

<p>I need it to get store element's ID, check to see if there was one. If there wasn't, set the new visible element to the default.</p>

<pre><code>$('#mainMenu a').mouseenter(function() {
    var newName = $(this).attr("id");
    if(newName == ''){
        var newName = "default";
    }
</code></pre>

<p>Then it checks to see if the new element matches the current one. If so, it returns. If not, it performs the animations to bring in the new one.</p>

<pre><code>    if(newName == currentSubNav){
     return;
    }else{
     $("div[name=" + currentSubNav + "]").animate({"left": "+=600px", "opacity": "toggle"}, "slow");
     $("div[name=" + newName + "]").css({"margin-top": "0"});
     $("div[name=" + newName + "]").fadeIn(2000);
     $("div[name=" + currentSubNav + "]").animate({"left": "-=600px"}, 0);
     currentSubNav = newName;
     return;
    }
});
</code></pre>

<p>I'm using Chrome at the moment, and according to the dev tools that isn't what happens.</p>

<p><strong>Problem #1</strong></p>

<p>"$(this).attr("id");" isn't returning undefined as the documentation claims. It seems to be returning "". BUT, when I have the if statement as I do above, it skips over the statement entirely. I set a breakpoint, but it never pauses execuation, so the statement is never evaluated.</p>

<p><strong>Problem #2</strong></p>

<p>After the animations occur, instead of using the return at the end of the statements it goes back and uses the return for the "newName == currentSubNav" if statement. I guess that not a big deal, but it's not the intended behavior.</p>

<p>I'm fairly new to JavaScript, and it appears I'm missing something about how JavaScript works. But I can't find what anywhere. Any help?</p>

<p><em>EDIT:</em> It seems to be working in FireFox, (though jQuery isn't returning undefined, it is returning ''). So this is a Chrome problem at the moment.</p>
