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.getElement sByTagName ("p").leng th; i++) {
if (document.getElementsByTag Name("p"). item(i).cl assName == "main"){
document.getElementsByTagN ame("p").i tem(i).sty le.color = "red";
}
}
}
//-->
</script>
#2:
-------------------------- ---------- ---------- --------
function changeSize(px){
var table = document.getElementById("t ableMain2" );
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!
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.getElement
if (document.getElementsByTag
document.getElementsByTagN
}
}
}
//-->
</script>
#2:
--------------------------
function changeSize(px){
var table = document.getElementById("t
table.setAttribute("width"
}
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER