由于form元素访问form表单对象中的子元素,可使用 document.form.inputName方式逐级访问表单元素。但是当form上name属性值为"verify"时候,如果通过上面方法当我需要取form的name属性时候那么去到取得到是将input对象。
那么就需要用下面方法取得属性值以避免这种问题:
[color=blue]
获取属性值 - getAttribute()
getAttribute("") 方法返回属性的值。
获取属性值 - getAttributeNode()
getAttributeNode("") 方法返回属性节点,getAttributeNode('').value取得节点值。
[/color]
两种方法区别是一个返回属性值,后者返回属性节点。
参考:
[url]http://www.veryide.com/archive.php?id=59[/url]
[url]http://qiqicartoon.com/?p=273[/url]
[url]http://www.howtocreate.co.uk/tutorials/javascript/dombasics[/url]
<form name="verify">
<input type="text" name="verify"/>
</form>
那么就需要用下面方法取得属性值以避免这种问题:
[color=blue]
获取属性值 - getAttribute()
getAttribute("") 方法返回属性的值。
获取属性值 - getAttributeNode()
getAttributeNode("") 方法返回属性节点,getAttributeNode('').value取得节点值。
[/color]
两种方法区别是一个返回属性值,后者返回属性节点。
参考:
[url]http://www.veryide.com/archive.php?id=59[/url]
[url]http://qiqicartoon.com/?p=273[/url]
[url]http://www.howtocreate.co.uk/tutorials/javascript/dombasics[/url]