$(document).ready(function() {
$(a).click(function(event) {
alert( You clicked a link to + this.href );
return false;
});
});
This method is very slow.
Try using event delegation:
$(document).ready(function() {
I'm trying to get href value from anchor tag.
code
$(document).ready(function() {
$(a).click(function(event) {
alert(As you can see, the link no longer took you to
jquery.com);
//$(a).html.href;
event.preventDefault();
});
});
a
$(a).attr(href);
But that would give you the href for the first A element in the document,
not necessarily the one you clicked.
Going back to the OP's code, this.href would be the easiest way to get it:
$(document).ready(function() {
$(a).click(function(event) {
alert( You clicked
Got it ..., thanks all
On Wed, Jan 20, 2010 at 1:22 PM, Michael Geary m...@mg.to wrote:
But that would give you the href for the first A element in the document,
not necessarily the one you clicked.
Going back to the OP's code, this.href would be the easiest way to get it:
5 matches
Mail list logo