HTML 페이지에서 줄의 색상을 변경하는 방법 (pre>의 텍스트) 특정 단어 포함 예를 들어 "ERROR"및 "Erreur"가 포함 된 모든 줄의 색상을 변경하고 싶습니다.
2014/05/22 02:27:02 - X.0 - Finished processing
2014/05/22 02:27:02 - DSA.0 - Finished processing
2014/05/22 02:27:03 - Block.0 - Finished processing
2014/05/22 02:27:03 - Errors CustomerGroupDimEU.0
2014/05/22 02:27:03 - Old = New ?.0 - Finished processing
2014/05/22 02:27:03 - Exists = 0.0 - Finished processing
이 코드는 단어 만 대체
(function ($) {
var thePage = $("body");
thePage.html(thePage.html().replace(/Error/ig, '<span style="color: red;font-weight: bold;">Error</span>'));
})
정규식은 까다로 웠습니다. 그러나 여기에 원하는 출력이 있습니다. :)
(function($) {
var thePage = $("body");
thePage.html(thePage.html().replace(/(^.*\b(Errors)\b.*)$/igm,
'<span style="color: red;font-weight: bold;">$1</span>'));
})(jQuery);
더 많은 키워드를 일치 시키려면 :
/(^.*\b(Errors|Error|Erreur)\b.*)$/igm
계속해서 키워드를 추가 할 수 있습니다. |
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다