How can I select an element by name with jQuery?

前端 未结 14 2795
迷失自我
迷失自我 2020-11-22 05:13

Have a table column I\'m trying to expand and hide:

jQuery seems to hide the td elements when I select it by class but not by element\'s name.

<
14条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 05:47

    You can use the jQuery attribute selector:

    $('td[name ="tcol1"]')   // matches exactly 'tcol1'
    $('td[name^="tcol"]' )   // matches those that begin with 'tcol'
    $('td[name$="tcol"]' )   // matches those that end with 'tcol'
    $('td[name*="tcol"]' )   // matches those that contain 'tcol'
    

提交回复
热议问题