Javascript 常用方法:document.getElementById(" ")
2014-12-21 19:56
337 查看
document.getElementById("") 返回对拥有指定id的第一个对象的引用。<tr><th>id</th><th>name</th><th>age</th><th>address</th></tr><tr><th>1</th><th>zhangsan</th><th id="age">24</th><th>江苏南京</th></tr><tr><th>2</th><th>lisi</th><th id="age">26</th><th>上海闵行</th></tr>$(function(){var obj = document.getElementById("age");alert(obj.innerHTML); // IE Google Firefox 24alert(obj.innerText); // IE Google 24 // Firefox undefined});<input type = "text" id = "text" value = "--请输入--"/><input type = "button" id = "button" value = "弹出text值">$("#button").click(function(){var objText = document.getElementById("text");alert(objText.value); // IE Google Firefox --请输入--});
相关文章推荐
- js节省document.getElementById("xxx")的方法
- document.getElementById("xxForm").submit();不起作用,无效方法??
- javascript代码在ie8里报错 document.getElementById(...) 为空或不是对象的解决方法 原创
- jquery中的$("#***")和javascript中document.getElementById相互转换
- jquery中的$("#id")与document.getElementById("id")的区别 及html()方法
- 【JavaScript】document.getElementById方法在Firefox与IE中的区别
- jsp页面javascript中用document.getElementById(" ").value无法获取相应text的值
- javascript在html中的加载顺序------为什么window.alert(document.getElementById("time").innerTex)无法弹出对话框
- javascript封装document.getElementById()方法
- javascript用$代替document.getElementById()方法
- document.getElementById("idName")用js方法获取元素,则设定风格属性的方法为
- javascript代码在ie8里报错 document.getElementById(...) 为空或不是对象的解决方法 原创
- Master Pages and JavaScript document.getElementById
- Java调用Document.getElementById方法返回null的解决办法
- JavaScript中也使用$美元符号来代替document.getElementById
- 母版页导致js 获取不到'document.getElementById("...").value 或 document.all("...").value
- document.getElementById("MyFile")和insertAdjacentHTML("beforeEnd", str)的含义和用法
- 在ASP.net中使用javascript的document.getElementById属性
- document.getElementById("radFs")对象为空,js判断对象是否存在?
- document.getElementById方法在Firefox与IE中的区别