1.源码 复aze代码 代码如下: <br>$(function() { <br>$("#btn_1").click(function() { <br>var $keyword = $("#Text1").val() <br>setHeightKeyWord(' bbb', $keyword, '빨간색', true) <br>}) <br>}); <br>function setHeightKeyWord(id, 키워드, 색상, 굵게) { <br>if (키워드 == "") <br>return; <br>var tempHTML = $("#" id).html(); <br>var htmlReg = new RegExp("<.*?>", "i"); <br>var arrA = new Array(); <br>for (var i = 0; true; i ) { <br>var m = htmlReg.exec(tempHTML); <br>if (m) { <br>arrA[i] = m; <br>} <br>else { <br>break; <br>} <br>tempHTML = tempHTML.replace(m, "[[[[" i "]]]]"); <br>} <br>var replacementText <br>if(굵게) <br>replaceText = "<b style='color:" color ";'>$1</b>"; <br>else <br>replaceText = "<font style='color:" color ";'>$1</font>"; <br>var arrayWord = 키워드.split(','); <br>for (var w = 0; w var r = new RegExp("(" arrayWord[w].replace(/[(){}. *?^$ |\[]]/g, "\$&") ")", "ig"); <br>tempHTML = tempHTML.replace(r, replacementText); <br>} <br>for (var i = 0; i < arrA.length; i ) { <BR>tempHTML = tempHTML.replace("[[[" i "]]]]", arrA[i ]); <BR>} <BR>$("#" id).html(tempHTML); <BR>} <BR>