get value of an attribute of the clicked element

后端 未结 3 1805
梦谈多话
梦谈多话 2020-12-29 21:01
  • english
  • francais
  • italiano
3条回答
  •  佛祖请我去吃肉
    2020-12-29 21:39

    This should do the job:

    $(document).ready(function() {
    
      $('#langs li').click(function() {
        alert($(this).attr('data-val'));
      });
    });
    

    Have a look at the Docs

提交回复
热议问题