get row with className

后端 未结 6 1644
甜味超标
甜味超标 2021-01-27 01:24

How can you get the first row in a table with a specific className?

var rows = $(\'tr\', tbl);
6条回答
  •  遇见更好的自我
    2021-01-27 02:04

    If you keep the proprietary :first selector out of it, you'll have a valid querySelectorAll selector.

    var rows = tbl.find('tr.someClass').slice( 0, 1 );
    

    or

    var rows = tbl.find('tr.someClass').eq( 0 );
    

    Also, using the context parameter $( selector, context ) is just a slower way of using the find()[docs] method.

提交回复
热议问题