views:

23

answers:

1

Hello,

I want to stylize only certain word from my dynamic div

say,

<div id="info">{$info}</div> prints

<p>here you can get info about somnething. if you want more info about something then click here....</p>

I only want stylize the word 'info'

How can I achieve this using jQuery?

Thanks.

A: 

Don't use jQuery to add styles to your HTML. You should generate proper HTML and then use CSS styling.


But if you still want to do this:

$("p").html( $("p").text().replace(/word/, "<span class='my-word'>word</span>") );

And in CSS:

.my-word { color: red; }
floatless