If anchor tag contains href attribute
<p>I want to be able to play a jQuery animation when a user clicks on a menu link. </p>

<p>In my script, I prevent the default behavior of the link, save the value of the anchor tag's href attribute in a variable, play the animation, and then redirect the window to the URL corresponding to the saved href value:</p>

<pre><code>&lt;script&gt;
jQuery(document).ready(function($) {
$('.main-navigation a').click(function(event) {
    event.preventDefault();

    var href = this.href;

    $('#main').slideUp(500,
    function() {
        window.location = href;
    });
  });
});
&lt;/script&gt;
</code></pre>

<p>The problem is, some of the anchor tags in my navigation menu do not have href attributes, because their only function is to open submenu on click. When I click on those menu items, the animation plays, and then the same page reloads. </p>

<p>I want to exclude the anchor tags that do not have href from the script's behavior. </p>

<p>My solution is to only save href for those anchor tags that actually have the href attribute. Except, I don't know how to do that. </p>

<p><strong>So, my question is:</strong> how should I express this with jQuery?</p>

<pre><code>if (anchor tag has href attribute) {
   var href = this.href;
}
</code></pre>

<p>Or perhaps there's a better solution?</p>
