<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<style type= "Text/css" >
. divred {
Border:solid 1px red;
}
</style>
<body>
<input type= "button" id= "value=" Testattribute "onclick=" Testattribute ();/>
<ol>
<li> (object. property) element is an object. The </li> property is the property of the object--the value of the custom property is not obtained;
<li> (object. Get/setatrribute) can manipulate custom properties--can only be used to obtain a constant value </li>
</ Ol>
<input type= "button" id= "value=" Testtext "onclick=" Testtext (); "/>
<ol>
<li>innerhtml</li>
<li>innertext</li>
</ol>
<input type= "button" id= "" value= "Testcss" onclick= "testcss ();"/>
<ol>
<li> </li>
<li> concrete style </li>
</ol>
<input type= "button" ID = "value=" Testnode "onclick=" Testnode ();/>
<input type= "text" id= "uname" value= "Beijing Shang Academy" abc= "123456"/>
<div id= "Showdiv" > Beijing Shang Academy is a good school </div>
<div id= "oper" class= "divred" >
<input type= "text" id= "school" value= "Beijing Shang Academy"/>
</div>
</body>
<script type= "Text/javascript" >
function Testattribute () {
var uname = document.getElementById ("uname");
Action Properties
Uname.value = "Shang Academy";
Uname.type = "button";
Alert (uname.value + "----" + uname.type);
Action Properties
Alert (Uname.getattribute ("type"));
Uname.setattribute ("Type", "button");
Alert (Uname.getattribute ("abc"));
Alert (Uname.getattribute ("value"));
}
function Testtext () {
var div = document.getElementById ("Showdiv");
Manipulating text
div.innerhtml = "Welcome to BJSXT";
alert (div.innerhtml);
div.innerhtml = "
}
function Testcss () {
var div = document.getElementById ("Showdiv");
Operation class
Div.classname = "divred";
Manipulating Specific styles
Div.style.height = "200px";
Div.style.width = "600px";
Div.style.backgroundColor = "Gray";
Div.style.lineHeight = "200px";
Div.style.fontSize = "40px";
div.style.textAlign = "center";
div.style.fontFamily = "in italics";
}
function Testnode () {
var div = document.getElementById ("oper");
var school = document.getElementById ("school");
Create a Node
var n = document.createelement ("input");
N.type = "button";
N.value = "BJSXT" + math.random ();
N.onclick = function () {
alert (this.value);
This.parentNode.removeChild (this);
};
Adding nodes
Div.appendchild (n);
Inserting nodes
Div.insertbefore (n, school);
Replace node
Div.replacechild (n, school);
Delete a node
Div.removechild (school);
}
</script>
JS operation HTML text, attributes, element nodes and CSS