/    Sign up×
Community /Pin to ProfileBookmark

innerText or textContent with Style

All,
I have the following code:

[CODE]
<div id=”upload_done”></div>

<script language=”javascript”>
function uploaderStatusChanged( uploader ) {
upload_status = uploader.getStatus()
if(upload_status==1){
traceEvent( “The files are being uploaded!” );
}else{
traceEvent( “The files have successfully uploaded!” );
}
}
</script>
<script language=”javascript”>
function traceEvent( message ) {
document.getElementById(“upload_done”).innerText = message; // for IE
document.getElementById(“upload_done”).textContent = message;
}
</script>
[/CODE]

When I use the innerText and textContent I’d like the font color to be red. How can I go about doing this? Also I tried to add some line breaks after the message but wasn’t able to do that either. I tried to do this:

[CODE]
<script language=”javascript”>
function traceEvent( message ) {
document.getElementById(“upload_done”).innerText = message + “nn”; // for IE
document.getElementById(“upload_done”).textContent = message + “nn”;
}
</script>[/CODE]

but was unsuccessful in that. Any help is appreciated. Thanks in advance.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@MarPloMar 01.2011 — Hy

Try use innerHTML

[b]document.getElementById("upload_done").innerHTML = '<font color="red">'+message+'</font><br />';[/b]
Copy linkTweet thisAlerts:
@treeleaf20authorMar 01.2011 — That did the trick, just wanted to confirm that innerHTML is ok for use cross browsers? In the other example I needed two different ones so just want to make sure that is not the same thing here. Thanks for the help.
×

Success!

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

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

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