链接 table 行和列 - jquery
chaining table rows and columns - jquery
我想知道如何使用链接在 jquery 中对此进行编码?
var table = document.getElementById("deliver_alt_table");
var rows = table.getElementsByTagName("tr");
$(rows[0].children[1]).css('visibility', 'hidden');
此代码有效 - 但如何使用一行 jquery 编写代码?
$("#deliver_alt_table") // sorta like getElementById()
.find("tr") // sorta like getElementsByTagName()
.eq(0) // sorta like how you did rows[0]
.children() // sorta like rows[0].children
.eq(1) // sorta like rows[0].children[1]
.css('visibility', 'hidden');
类似...
$("#deliver_alt_table tr:first > *:eq(1)").css("visibility", "hidden");
编辑: 将 "nth-of-type" 更改为 "eq"
我想知道如何使用链接在 jquery 中对此进行编码?
var table = document.getElementById("deliver_alt_table");
var rows = table.getElementsByTagName("tr");
$(rows[0].children[1]).css('visibility', 'hidden');
此代码有效 - 但如何使用一行 jquery 编写代码?
$("#deliver_alt_table") // sorta like getElementById()
.find("tr") // sorta like getElementsByTagName()
.eq(0) // sorta like how you did rows[0]
.children() // sorta like rows[0].children
.eq(1) // sorta like rows[0].children[1]
.css('visibility', 'hidden');
类似...
$("#deliver_alt_table tr:first > *:eq(1)").css("visibility", "hidden");
编辑: 将 "nth-of-type" 更改为 "eq"