Javascriptを使用してH1タグをH2に変更します[クローズ]
Aug 20 2020
Vanilla JavaScriptで、このHTMLコードの<h1>
タグを<h3>
タグに変更する方法を探しています。
<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/