javascript:在dom中查找字符串并强调它 [英] javascript: find strings in dom and emphasize it

查看:111
本文介绍了javascript:在dom中查找字符串并强调它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个函数,可以找到一些我在DOM中的数组中的字符串,并强调它。

i want a function that finds some strings i've got in an array in the DOM and emphasize it.

eg。

keywords[0] = 'linux';
keywords[1] = 'suse pro';







<body>
    im a huge fan of <em>linux</em> and at the moment im using <em>suse pro</em> and finds it amazing.
</body>

我如何以最简单的方式执行此操作。感谢提前

how do i do it in the easiest way. thanks in advance

编辑:我发现一个非常简单的方法来完成这个:jquery突出显示插件!欢呼!

i found a very easy way to accomplish this: jquery highlight plugin! cheers!

推荐答案

有一个jQuery插件,这样做:
http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting -jquery-plugin.html

there's a jquery plugin that does this: http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html

这篇关于javascript:在dom中查找字符串并强调它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆