1. Source Code
Copy Code code as follows:
<script type= "Text/javascript" >
$ (function () {
$ ("#btn_1"). Click (function () {
var $keyword = $ ("#Text1"). Val ()
Setheightkeyword (' BBB ', $keyword, ' Red ', true)
});
});
function Setheightkeyword (ID, keyword, color, bold) {
if (keyword = "")
Return
var temphtml = $ ("#" + ID). HTML ();
var htmlreg = new RegExp ("\<.*?\>", "I");
var arra = new Array ();
for (var i = 0; true; i++) {
var m = htmlreg.exec (temphtml);
if (m) {
Arra[i] = m;
}
else {
Break
}
temphtml = Temphtml.replace (M, [[[[] + i +]]];
}
var replacetext
if (bold)
ReplaceText = "<b style=" color: "+ color +"; >$1</b> ";
Else
ReplaceText = "<font style=" color: "+ color +"; >$1</font> ";
var Arrayword = Keyword.split (', ');
for (var w = 0; w < arrayword.length; w++) {
var r = new RegExp ("(" + Arrayword[w].replace (/[() {}.+*?^$|\\\[\]]/g, "\\$&") + ")", "IG");
temphtml = Temphtml.replace (R, ReplaceText);
}
for (var i = 0; i < arra.length; i++) {
temphtml = Temphtml.replace ("[[[[[] + i +"]]]] ", arra[i]);
}
$ ("#" + ID). HTML (temphtml);
}
</script>