Jump to content

style.color...?


Beta
 Share

Recommended Posts

<span style="color: rainbow"></span><script type="text/javascript"><!--var Span = document.getElementsByTagName("span");for(e = 0; e < Span.length; e++) {   if(Span[e].style.color == "rainbow") {   Span[e].innerHTML = "RAINBOW!!!";   }}// --></script>

Anyone know why that doesn't work? I'm thinking it's because "rainbow" isn't a default color...but should that even matter? o.o

Link to comment
Share on other sites

<span style="color: rainbow"></span><script type="text/javascript"><!--var Span = document.getElementsByTagName("span");for(e = 0; e < Span.length; e++) {   if(Span[e].style.color == "rainbow") {   Span[e].innerHTML = "RAINBOW!!!";   }}// --></script>

Anyone know why that doesn't work? I'm thinking it's because "rainbow" isn't a default color...but should that even matter? o.o

I don't believe the HTML allows that. :)
Link to comment
Share on other sites

When I run the code in Firefox it says "Expected color but found 'rainbow'. Error parsing value for property 'color'. Declaration dropped."So, in firefox, the color for the span is never set to "rainbow" so the javascript can't find a span element with that color property. If you change the color from "rainbow" to "red" in both the HTML and in the javascript it works.

Link to comment
Share on other sites

There isn't, but i've made a prototype function that makes a String glow random colors at a setInterval rate....so i was trying to make it find that span tag instead of looking for a tag that i create myself :/See, this is all for an InvisionFree forum. The tag auto-parses to a span with the color value assigned to it. i wanted to try [color*=rainbow], as it creates a span with that color already assigned, so that i would have to parse the tag myself :/ but i guess theres no real way around it as the HTML doesn't even allow it :)...lol

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...