Jquery获取href值

Mo.*_*Mo. 0 javascript jquery jquery-ui

我需要从href按钮获取值.这里我刚刚开发了一个显示所有href值的代码.实际上我需要从我点击的位置获取价值.

这是我的代码

$(document).ready(function() {
  $("a.me").click(function(){
    var number = $('a').text();

    alert(number);

  });
}); 
Run Code Online (Sandbox Code Playgroud)

Nic*_*tti 5

你应该做

$(document).ready(function() {
  $("a.me").click(function(){
    //It's not clear if you want the href attribute or the text() of the <a>
    //this gives you the href. if you need the text $(this).text();
    var number = this.href;
    alert(number);

  });
}); 
Run Code Online (Sandbox Code Playgroud)