자바 스크립트를 사용하여 H1 태그를 H2로 변경 [닫힘]
Aug 20 2020
이 HTML 코드 의 <h1>
태그를 <h3>
태그 로 변경하는 방법을 Vanilla JavaScript에서 찾고 있습니다.
<h1 class="price-heading ult-responsive cust-headformat" data-ultimate-target="#price-table-wrap-3686 .cust-headformat" data-responsive-json-new="{"font-size":"","line-height":""}" style="font-family:'Roboto';font-weight:bold;">Basic</h1>
이것을 어떻게 달성 할 수 있습니까?
답변
1 Dalibor Aug 20 2020 at 15:50
var el = document.getElementsByTagName('h1')[0];
var dummy = document.createElement('h2');
dummy.innerHTML = el.innerHTML;
el.parentNode.replaceChild(dummy, el);
https://jsfiddle.net/Lzg47mek/