- innerhtml //innerHTML 属性设置或返回表格行的开始和结束标签之间的 HTML.
- innertext//innerText 属性返回文本值 没有结构信息
$("#test").text() 或者 $("#test").innerText
$("#test").HTML() 或者 $("#test").innerHTML
- <-- 操作节点 -->
- getAttribute("属性名")//getAttribute() 方法返回指定属性名的属性值.
- // 如果您希望以 Attr 对象返回属性, 请使用 getAttributeNode.
- setAttribute("属性名","属性值")
- element.getAttribute(attributename)
参数 [attributename] 字符串值. 必需. 需要获得属性值的属性名称.
返回值 [类型] String 指定属性的值.
- <-- 创建节点 -->
- A.appendChild( B) // 把 B 节点追加至 A 节点的末尾
- createElement( tagName) // 创建一个标签名为 tagName 的新元素节点
- insertBefore( A,B ) // 把 A 节点插入到 B 节点之前
cloneNode(deep) // 复制某个指定的节点
- <-- 删除和替换 -->
- removeChild( node) // 删除指定的节点
replaceChild( newNode, oldNode) 属性 attr // 用其他的节点替换指定的节点
- Element.style.border // 只能获取 行内样式
- getComputedStyle// 谷歌 火狐 获取行外样式
- curre // 兼容 IE
- 1.valueOf()
valueOf() 方法可返回 Boolean 对象的原始值.
2.getElementById() [得到一个元素] {id 是唯一的}
getElementById() 方法可返回对拥有指定 ID 的第一个对象的引用.
3.getElementsByName() [得到一组 即多个元素] {name 是可重复的}
它查询元素的 name 属性, 而不是 id 属性.
另外, 因为一个文档中的 name 属性可能不唯一 (如 HTML 表单中的单选按钮通常具有相同的 name 属性) 所有 getElementsByName() 方法返回的是元素的数组, 而不是一个元素.
4.getElementsByTagName() [以标签为分类]
getElementsByTagName() 方法可返回带有指定标签名的对象的集合.
例子:
- var tables = document.getElementsByTagName("table");
- alert ("This document contains" + tables.length + "tables");
5.indexOf() 方法可返回某个指定的字符串值在字符串中首次出现的位置.
语法
stringObject.indexOf(searchvalue,fromindex)
参数 描述
searchvalue 必需. 规定需检索的字符串值.
fromindex 可选的整数参数. 规定在字符串中开始检索的位置. 它的合法取值是 0 到 string Object.length - 1. 如省略该参数, 则将从字符串的首字符开始检索.
来源: http://www.bubuko.com/infodetail-3136008.html