如何使用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
相關文章
相關標籤/搜索