/    Sign up×
Community /Pin to ProfileBookmark

changing td table and tr bgcolors

I am working on a script, that has a prompt that allows the user to input a color. I gave it the var theground. I have managed to use this to change the bg of the page. what I am wondering is how can I use it to change the bg of a td tr or table? I also have a cookie that remebers the color for each page. I tried this

[code]
<script language=”JavaScript”>
function alternate(id) {
document[id].style.backgroundColor = theground;
}
</script>

<body onload=”alternate(‘thetable’)”>
<table width=”400″ border=”0″ cellpadding=”0″ cellspacing=”0″>
<tr id=”thetable”>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td></td>
<td>&nbsp;</td>
</tr>
[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@KorJun 23.2005 — function alternate(id,theground) {

document.getElementById(id).style.backgroundColor = theground;

}

...

<body onload="alternate('thetable','#CCFF00')">
×

Success!

Help @earlwallace4th spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...