3

タイトルはかなり自明です。

$(".js").click(function (e) {
        alert('this elements href is: ' + href);
    });

「href」をクリックした要素の href に置き換えるにはどうすればよいですか?

4

2 に答える 2

6

このような:

$(".js").click(function (e) {
    alert('this elements href is: ' + $(this).attr('href'));
}
于 2012-07-18T07:04:23.307 に答える
3

これを試して:

alert('this elements href is: ' + this.href);//best one

または

alert('this elements href is: ' + $(this).attr("href"));//but it is unnecessary to wrap an object into another object
于 2012-07-18T07:05:59.980 に答える