FrontEnd/Javascript
html 태그 제거 <p><span><div>
ejyoovV
2021. 7. 8. 21:34
1. 전체태그 제거
var text = '<div>Remove all tag</div><span>test123123</span>';
var newText = text.replace(/(<([^>]+)>)/ig,"");
alert(newText);
2. span태그 제거
var text = '<span>Remove Span tag only</span>';
var newText = text.replace(/<(\/span|span)([^>]*)>/gi,"");
alert(newText);
// span 태그가 제거된 'Remove Span tag only' 출력