1、js操作element对象
<input type="text" name="uNamesss" id="id1" value="abc"/>
<ul id="ul2">
<li>uk</li>
<li>usa</li>
</ul>
<script type="text/javascript">
//获取到ul下面的子元素
var ul2 = document.getElementById("ul2");
var arr = ul2.childNodes;
alert("length1: "+arr.length);// 2
var arr1 = ul2.getElementsByTagName("li");
alert("length2: "+arr1.length); //2
//获取到input
var inputs = document.getElementById("id1");
alert(inputs.value); //abc
alert(inputs.getAttribute("name"));//uNamesss
//setAttribute
alert(inputs.getAttribute("class")); //null
inputs.setAttribute("class","haha");
alert(inputs.getAttribute("class"));//haha
//removeAttribute
alert(inputs.getAttribute("name"));//uNamesss
inputs.removeAttribute("name");
alert(inputs.getAttribute("name"));//显示空串
//注意通过removeAttribute,不能删除value
alert(inputs.getAttribute("value"));//abc
inputs.removeAttribute("value");
alert(inputs.getAttribute("value"));//abc
</script>