...

View Full Version : Match() String help



feras_wilson
12-12-2006, 07:48 PM
Hi all!
I need some help with this code:


<script>
str = new String("Hello World")
document.write(str.match('Hello').fontcolor("blue"))
</script>

I want the word "Hello" of the string to have a blue color. Not the hole string JUST the "Hello" word.:confused: :confused: :confused: :confused:

liorean
12-12-2006, 08:01 PM
With the following CSS
.hello{
color: blue;
}you can write the script like this:
var
str='Hello World';
alert(str.replace(/Hello/g,'<span class="hello">$&</span>'));

feras_wilson
12-12-2006, 08:09 PM
How i do it if i have the "Hello" word in a textarea.


<textarea>
Hello World
</textarea>

Help Please



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum