글

라벨이 html인 게시물 표시

Javascript add a tag to http url word (http url 에 a tag 추가)

function addATagToHttpUrl ( text ) { return text . replace ( / \b http\S + / g , function ( x ) { return "<a target='_blank' href='" + x + "'>" + x + "</a>" ; }); }

Javascript replace new line with br tag (줄바꿈을 br tag로 변환)

function replaceNewLineWithBr ( text ) { return text . replace ( / (?: \r\n | \r | \n ) / g , "<br />" ); }

Javascript remove html tag (html tag 제거)

// remove html tags function removeTags ( text ) { var div = $ ( '<div/>' ); div . html ( text ); div . contents (). filter ( function () { return this . nodeType !== 3 ; }). after ( function () { return $ ( this ). text (); }). remove (); return div . text (); }