Link to home
Create AccountLog in
Avatar of seamusseamus
seamusseamus

asked on

switching table attributes with JS

Hi there,

I'm trying to do a merge of the following two scripts:


#1:
------------------------------------------------------
<body onload="classChange();">
<script type="text/javascript">
<!--
function classChange() {
      for (i=0;i<document.getElementsByTagName("p").length; i++) {
            if (document.getElementsByTagName("p").item(i).className == "main"){
                  document.getElementsByTagName("p").item(i).style.color = "red";
            }
      }
}
//-->
</script>


#2:
------------------------------------------------------
function changeSize(px){
   var table = document.getElementById("tableMain2");
   table.setAttribute("width",px);
}


The issue is that I need to change the hard coded width of a table that only has class="main" attributed to it.  Unfortunately, I cannot change the HTML code.

Thanks!

ASKER CERTIFIED SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of seamusseamus
seamusseamus

ASKER

sorry for the delay in accepting this answer... worked like a charm!