java java - 2 years ago 111
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');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download