본문 바로가기
자바스크립트

문자열인 태그를 html에서 태그로 인식하게 하기 (정규식)

by 찬찬2 2020. 12. 22.

   $(".OP_TEXT").each(function(){

                            $(this).html($(this).html().replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">") );

                        })

 

 

var txt = "This is an apple.";
var new_txt = txt.replace("apple", "pineapple");
=> This is an pineapple.

var txt = "This is an apple."; var new_txt = txt.replace("apple", "pineapple"); => This is an pineapple.

'자바스크립트' 카테고리의 다른 글

[jQuery Template] 문법  (0) 2020.12.29
정규식 시각화, 빌드 [정규식 모음]  (0) 2020.12.23
.each( ) 와 $.each( ) 의 사용  (0) 2020.12.16
DOM insertion ( html( ), text( ) )  (0) 2020.12.16
css( )에 대해...  (0) 2020.12.16

댓글