Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 869
java Avatar asked Mar 11 '23 23:03

java


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');
like image 178
I wrestled a bear once. Avatar answered Mar 23 '23 21:03

I wrestled a bear once.


Something like...

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

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

like image 35
m-albert Avatar answered Mar 23 '23 23:03

m-albert