View Full Version : run a element specific function on page load

11-09-2012, 06:02 PM

sort of a simple one, kinda new to JS, so this has me stumped.

have the below code that minimizes / max a column in a table with max and min hiperlinks - the idea is, there is alot of data to display, so this hides the huge data in certain columns untill the user wants to view it.

all i want is for the columns to be minamized on page load. but i am not sure how to do this as the JS function uses a passed page element var. so in short just want to run the below on page load, but I have mutaple cols with min and max in the first td

$("thead a").click(function(){
var myIndex = $("thead td").index($(this).parent());
var pxWidth = ($(this).attr("href") == "#max") ? "auto" : "5px";
var hideContents = ($(this).attr("href") == "#max") ? false : true;

$("thead tr").each(function(){
$("tbody tr").each(function(){
var el = $("td",this).eq(myIndex);
return false;

any help is appreciated!