java java - 1 year ago 77
jQuery Question

chaining table rows and columns - 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 could it be written in jquery using one row?

Answer Source
$("#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');