1. document
2. body
获取body元素:document.body
3. 遍历使用Jquery 获取的dom数组,可以使用each(func)方法。
例如:
$('oes-table').find('.ckbox input').each(function addId(index,item){item.setAttribute('id','ckbox_'+index)});
addId 方法的index 和item 分别表示正在遍历的Dom序号和该Dom本身。
4. 常用属性,方法:
innerHTML:获取dom 的HTML元素
修改dom的class属性:
Jquery:
$(dom).addClass("XXX").removeClass("XXX");
原生JS:
dom.setAttribute('class','XXX');或者dom.className('XXX');
document.getElementById(str);//获取ID为str的dom节点
document.getElementByName(str);//获取Name属性为str的dom节点
document.getElementByTagName(str);//获取类型为str的dom节点
document.createElement(str);//创建类型为str的dom节点
document.createTextNode(str);//创建内容为str的dom节点
appendChild(dom);//向父dom中添加子dom节点
removeChild(dom);//在父dom中移除子dom节点
setAttribute(str,str);//设置某个dom元素的某属性为具体值