Home > Web Front-end > JS Tutorial > body text

I will explain to you in detail how to create div, span, and label in js through code.

亚连
Release: 2018-05-18 11:13:21
Original
2566 people have browsed it

The following is what I have compiled for you on how to create div, span, and label in js. Interested students can take a look.

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);
Copy after login

The above is how to create div, span, label in js. I hope it will be helpful to everyone in the future. .

Related articles:

How to establish a model data model in js (the code is provided, simple and easy to understand)

Native JS implementation method to determine collision (interesting example)

About simple calls to obtain JSON data in JS (code attached, simple and crude)

The above is the detailed content of I will explain to you in detail how to create div, span, and label in js through code.. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!