Table row and column chain - jquery

I would like to know how I could code this in jquery using chaining?

var table = document.getElementById("deliver_alt_table");
var rows = table.getElementsByTagName("tr");
$(rows[0].children[1]).css('visibility', 'hidden');

This code works, but how can it be written in jquery with a single line?

+4
source share
2 answers
$("#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');
+5
source

Sort of...

$("#deliver_alt_table tr:first > *:eq(1)").css("visibility", "hidden");

EDIT: Changed "nth-of-type" to "eq"

+2
source

All Articles