下面是我给大家整理的如何在js中创建div,span,label,有兴趣的同学可以去看看。
var newdiv=document.createElement("div"); newdiv.className="switch-animate switch-on" newdiv.id="switch_div" document.getElementById("dhcpd_div").appendChild(newdiv); var rinput = document.createElement("input"); rinput.setAttribute("type","checkbox"); rinput.setAttribute("name","dhcpd_name"); rinput.setAttribute("id",'dhcpd'); document.getElementById('switch_div').appendChild(rinput); rinput.setAttribute("checked",'checked'); var spanON = document.createElement("span"); spanON.className = "switch-left switch-success"; spanON.innerHTML = "ON"; document.getElementById("switch_div").appendChild(spanON); var label_var = document.createElement("label"); label_var.innerHTML = " "; document.getElementById("switch_div").appendChild(label_var); var spanOFF = document.createElement("span"); spanOFF.className = "switch-right switch-warning"; spanOFF.innerHTML = "OFF"; document.getElementById("switch_div").appendChild(spanOFF);
上面是我整理给大家的如何在js中创建div,span,label,希望今后会对大家有帮助。
相关文章:
Atas ialah kandungan terperinci 通过代码详细为你讲解如何在js中创建div,span,label. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!