javascript - change color of special characters in HTML -
i've unicode html page (saved in db), there anyway can programmatically change color of "." , ":" characters in text (please pay attention html content has inline css may contain "." or ":" characters, want change color of mentioned characters in real text.
what options? 1 way can finding these characters in text , put them in tag, can styled, other suggestion? (if i'm going use method, how can distinguish between html/css characters , real characters in text?) i'm using asp.net/c#
try utilizing string.prototype.replace()
regexp
/\.|:/g
, returning i
element style
attribute set specific color
var div = document.getelementsbytagname("div")[0]; div.innerhtml = div.innerhtml.replace(/\.|:/g, function(match) { return "<i style=color:tomato;font-weight:bold>" + match + "</i>" })
<head> <meta charset="utf-8" /> </head> <body> <div> i've unicode html page (saved in db), there anyway can programmatically change color of "." , ":" characters in text (please pay attention html content has inline css may contain "." or ":" characters, want change color of mentioned characters in real text. options? 1 way can finding these characters in text , put them in tag, can styled, other suggestion? (if i'm going use method, how can distinguish between html/css characters , real characters in text?) i'm using asp.net/c# </div> </body>
Comments
Post a Comment