タイトルはかなり自明です。
$(".js").click(function (e) {
alert('this elements href is: ' + href);
});
「href」をクリックした要素の href に置き換えるにはどうすればよいですか?
タイトルはかなり自明です。
$(".js").click(function (e) {
alert('this elements href is: ' + href);
});
「href」をクリックした要素の href に置き換えるにはどうすればよいですか?
このような:
$(".js").click(function (e) {
alert('this elements href is: ' + $(this).attr('href'));
}
これを試して:
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