Get attribute of child element

前端 未结 5 450
温柔的废话
温柔的废话 2020-12-30 23:28

If I have the following markup:

Hours&am

5条回答
  •  伪装坚强ぢ
    2020-12-31 00:03

    $("a span[sortcat]").attr('sortcat')
    

    That'll give you the first element's sortcat value. To get all of them, do this:

    $("a span[sortcat]").map(function(){ return $(this).attr('sortcat') })
    

    See this working demo: http://jsfiddle.net/BwgDW/

提交回复
热议问题