如何使用jQuery按名称选择元素? - How can I select an element by name with jQuery?

问题:

Have a table column I'm trying to expand and hide: 有一个表格列我正在尝试展开和隐藏: jquery

jQuery seems to hide the td elements when I select it by class but not by element's name . 当我按而不是按元素名称选择时,jQuery彷佛隐藏了td元素。 ide

For example, why does: 例如,为何: this

$(".bold").hide(); // selecting by class works
$("tcol1").hide(); // select by element name does not work

Note the HTML below, the second column has the same name for all rows. 请注意下面的HTML,第二列对全部行都具备相同的名称。 How could I create this collection using the name attribute? 如何使用name属性建立此集合? spa

<tr>    
    <td>data1</td>
    <td name="tcol1" class="bold"> data2</td>
</tr>
<tr>    
    <td>data1</td>
    <td name="tcol1" class="bold"> data2</td>
</tr>  
<tr>    
    <td>data1</td>
    <td name="tcol1" class="bold"> data2</td>
</tr>

解决方案:

参考一: https://stackoom.com/question/4e2O/如何使用jQuery按名称选择元素
参考二: https://oldbug.net/q/4e2O/How-can-I-select-an-element-by-name-with-jQuery
相关文章
相关标签/搜索