search

Home  >  Q&A  >  body text

请问a标签onlick事件获取当前data-name

请问a标签onlick事件获取当前data-name


大家讲道理大家讲道理3022 days ago686

reply all(2)I'll reply

  • 代言

    代言2016-11-12 14:46:59

    $(this).attr('data-name');

    reply
    0
  • 代言

    代言2016-11-12 14:46:52

    绑定事件的时候把this传进去,onclick="choose(this)"

    function choose(x){
    alert(x.getAttribute("data-name"))
    }


    reply
    0
  • Cancelreply