开发者

Jquery to stylize only certain word from para

I want to stylize only certain word from my dynamic div

say,

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

<p>her开发者_开发技巧e 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.


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; }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜