By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,568 Members | 1,196 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,568 IT Pros & Developers. It's quick & easy.

how to make color in innerHTML

P: 77
Hello, i want to make a color in the text of innerHTML with this script

Expand|Select|Wrap|Line Numbers
  1. <script language = "javascript">
  2. var color = "FFF000"; 
  3. document.getElementById('showEmailValidation').innerHTML = "<font color=#"+color+">"test"</font>";
  4.  
  5. </script>
but it didn''t succeed, any idea??
Jul 22 '08 #1
Share this Question
Share on Google+
5 Replies


P: 77
For your information, the fault is not in "inn erHTML", i only wrong in putting the script into this editor,...

so, any idea???
Jul 22 '08 #2

P: 77
For your information, the fault is not in "inn erHTML", i only wrong in putting the script into this editor,...

so, any idea???

ok/...sorry, i';ve already solved the problem...

So to solve that problem, the script become like this one below :

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2.  
  3. var color = "#FF0000";
  4. document.getElementById('showEmailValidation').innerHTML = "<font color="+color+">test</font>";
  5.  
  6. </script>
  7.  
thanks for all,,,

best regards, mamin
Jul 22 '08 #3

P: 77
ok/...sorry, i';ve already solved the problem...

So to solve that problem, the script become like this one below :

<script language="javascript">

var color = "#FF0000";
document.getElementById('showEmailValidation').inn erHTML = "<font color="+color+">test</font>";

</script>


thanks for all,,,

best regards, mamin

and again,,,the "innerHTML" (no empty space) is always printed become "inn erHTML"(there is an empty space) in the display,

just ignore that...tks
Jul 22 '08 #4

gits
Expert Mod 5K+
P: 5,343
glad to hear that you found the mistake for yourself and for posting the solution. all attribute values should be in quotes always and one more note: just leave the language attribute of the script-tag ... it's deprecated ... just use the type attribute instead like this:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
kind regards
Jul 22 '08 #5

P: 77
glad to hear that you found the mistake for yourself and for posting the solution. all attribute values should be in quotes always and one more note: just leave the language attribute of the script-tag ... it's deprecated ... just use the type attribute instead like this:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
kind regards

ok thanks...

kind regards :)
Jul 22 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.