How do I get anchor href value on click using jQuery?
<p>Let's say I have an anchor like this:</p>

<pre><code>&lt;a onClick="return confirm('Sure?')" href="http://stackoverflow.com/"&gt;Click here&lt;/a&gt;
</code></pre>

<p>Is there anyway I can get the value of href "http://stackoverflow.com/" when I click "Click here"? Bearing in mind that I don't have other attributes to help, such as id or name!</p>

<p>I'm overriding the confirm function and I need to redirect the user to the location provided in the anchor if they clicked ok as follows:</p>

<pre><code>window.confirm = function(msg) {
      var targetUrl = jQuery(this).attr("href");
      jQuery("#alert_box").dialog({
         autoOpen: false,
         show: "slide",
         modal: true,
         width: 400,
         resizable:false,
         title: '&lt;img src="icons/confirm.png" /&gt; Confirm!',
         buttons: { "Cancel": function() { 
                        jQuery(this).dialog("close");                       
                    },
                 "OK": function() { 
                        //jQuery(this).dialog("close");
                        jQuery(location).attr('href', targetUrl);
                    }
                   }
      });

      jQuery("#alert_box").html(msg);
      jQuery("#alert_box").dialog("open");
      return false;
  }
</code></pre>

<p>Any help would be much appreciated!</p>
