/    Sign up×
Community /Pin to ProfileBookmark

simple: Change the color of checkbox text

How can i change the color of the text that accompanies a checkbox.

[CODE]
<html>
<head>
<script type=”text/javascript” src=”testFunctions.js”></script>
<script type=”text/javascript”>
function test(){

document.getElementById( ‘append’ ).innerHTML = “”;

var divTag = document.createElement(“div”);
divTag.className =”checkBox”;

var cb = document.createElement( “input” );
cb.type = “checkbox”;
cb.id = “checkBox”;
cb.name = “checkBox”;
cb.checked = true;
cb.value = “checkBox”;

document.getElementById(“append”).appendChild(divTag);
divTag.appendChild(cb);

var textNode = document.createTextNode(“This is a check box”);

divTag.appendChild(textNode);

}
</script>

</head>

<body>
<p>click the button below</p>
<div id=”append” name=”append”></div>

<input type=”button” value=”createCheckBoxes” onclick=”test()” />

</body>
</html>[/CODE]

I have tried

[CODE]textNode.style.color = “blue”;[/CODE]

or

[CODE]cb.value.style.color = “blue”[/CODE]

But neither work……

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangOct 24.2008 — divTag.style.color = "blue"
Copy linkTweet thisAlerts:
@PalliauthorOct 24.2008 — so simple! thanks
×

Success!

Help @Palli 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...