Мне нужно преобразовать innline css во внешний css, у кого-нибудь есть идеи как? Как разделить html и css и вставить их в div-html и div-css.
Например:
Из этого:
<div id="one" style="background-color:green;width:50px;height:50px;">Div one</div>
к этому:
<div id="one">Div one</div>
#one{
background-color:green;
width:50px;
height:50px;
}
Вот так это будет выглядеть:
<div id="container"
<div id="one" style="background-color:green;width:50px;height:50px;">Div one</div>
<div id="two" style="background-color:red;width:150px;height:150px;">
<div id="three" style="background-color:blue;width:50px;height:50px;">Div three</div>
</div>
</div>
<div id="html"></div>
<div id="css"></div>
<button onclick="myFunction()" >click</button>
<script>
function myFunction(){
var x = document.getElementById("container").innerHTML
var html =
var css =
document.getElementById("html").innerHTML = html;
document.getElementById("css").innerHTML = css;
}
</script>