您的位置:首页 > Web前端 > JavaScript

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 --请输入--});

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐