var style = document.createElement("style");
style.type = "text/css";
style.textContent = ".main{background-color: green;width: 100%;height: 400px;}";
document.head.appendChild(style);
var $html = "<div class='topDiv'><button>点我登录</button> <select><option>请选择</option><option>1</option><option>2</option></select></div>";
var div = document.createElement("div");
div.innerHTML = $html;
document.body.appendChild(div);
var $html1 = "<div class='leftDiv'><p>左边</p></div>";
var div1 = document.createElement("div");
div1.innerHTML = $html1;
document.body.appendChild(div1);
评论区