window.document 对象
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript"> function getById(id)
{
//根据id查找 var aa = document.getElementById(id); aa.style.backgroundColor="#FFF"; alert(aa);
/* alert("innerHTML = " + aa.innerHTML);
alert("outerHTML" + aa.outerHTML);
alert("innerText" + aa.innerText); aa.innerText = "";*/ } function getByName(name)
{
//根据id查找
//var aa = document.getElementById(id); var aa = document.getElementsByName(name); alert(aa); if (aa.length > 0)
{
alert(aa[0].innerText);
} /*alert("innerHTML = " + aa.innerHTML);
alert("outerHTML" + aa.outerHTML);
alert("innerText" + aa.innerText); aa.innerText = "";*/
} function getByTagName(name)
{
var aa = document.getElementsByTagName(name); alert(aa); if (aa.length > 0)
{
for (var i = 0; i < aa.length; i++)
alert(aa[i].innerText);
} /*alert("innerHTML = " + aa.innerHTML);
alert("outerHTML" + aa.outerHTML);
alert("innerText" + aa.innerText); aa.innerText = "";*/
} function getByClassName(name)
{
var aa = document.getElementsByClassName(name); alert(aa); if (aa.length > 0)
{
for (var i = 0; i < aa.length; i++)
alert(aa[i].innerText);
} /*alert("innerHTML = " + aa.innerHTML);
alert("outerHTML" + aa.outerHTML);
alert("innerText" + aa.innerText); aa.innerText = "";*/
} function getByForm()
{
try
{
var aa = document.myForm.f6; alert(aa.value); aa.value = "新的内容"; aa.setAttribute("newvalue", "新属性值"); var bb = aa.getAttribute("daan") alert(bb); aa.removeAttribute("newvalue"); bb = aa.getAttribute("newvalue"); alert(bb);
}
catch(ex)
{
alert(ex);
}
} </script>
</head> <body> <div style="background-color:#F00; height:100px;" id="a" name="b" ><b>这是另一个元素</b></div>
<div class="c" id="ab"><b>这是一个元素</b></div> <form name="myForm" action="#" method="get" > <br /> <input id="f1" type="button" onclick='getById("a");' value="根据ID查找元素" /> <br /> <input id="f2" type="button" onclick='getByName("b");' value="根据Name查找元素" /> <br /> <input id="f3" type="button" onclick='getByTagName("div");' value="根据TagName查找元素" /> <br /> <input id="f4" type="button" onclick='getByClassName("c");' value="根据ClassName查找元素" /> <br />
<input id="f6" daan="1921年" type="text" width="30" value="内容" /> </form> <br /> <input id="f5" type="button" onclick='getByForm();' value="查找表单元素" /> </body>
</html>
window.document 对象的更多相关文章
- Window.document对象
1.Window.document对象 一.找到元素: docunment.getElementById("id"):根据id找,最多找一个: var a =docunme ...
- JavaScript的DOM操作。Window.document对象
间隔执行一段代码:window.setlnteval("需要执行的代码",间隔毫秒数) 例 : window.setlnteval("alert("你 ...
- Window.document对象 轮播练习
Window.document对象 一.找到元素: docunment.getElementById("id"):根据id找,最多找一个: var a =docun ...
- HTML Window.document对象
1.Window.document对象 一.找到元素: docunment.getElementById("id"):根据id找,最多找一个: var a =docunmen ...
- Window.document对象(1)
1.Window.document对象 一.找到元素: docunment.getElementById("id"):根据id找,最多找一个: var a =docunme ...
- JS中window.document对象
小知识点注:外面双引号,里面的双引号改为单引号: 在div里面行高设置和整个外面高度一样,才能用竖直居中,居中是行居中 文本框取出来 ...
- 1、Window.document对象
1.Window.document对象 一.找到元素: docunment.getElementById("id"):根据id找,最多找一个: var a =docunmen ...
- 3.26课·········window.document对象
1.Window.document对象 一.找到元素: docunment.getElementById("id"):根据id找,最多找一个: var a =docun ...
- 2016/2/22 1、Window.document对象
1.Window.document对象 一.找到元素: docunment.getElementById("id"):根据id找,最多找一个: var a =docunme ...
- DOM操作(Window.document对象)
间隔与延迟: 间隔一段代码: window.setInterval("代码",间隔执行秒数) 延迟一段时间后执行一段代码: window.setTimeout("执行代码 ...
随机推荐
- 6kzz整合ueditor
用过6kzz免费版的朋友都知道,它的后台编辑器是kindeditor,并且是两三年前的版本,有很多功能都没有,现在的kindeditor也不错,但感觉还是没有百度的ueditor强大(据说微信后台的编 ...
- android httpclient 设置超时
3.X是这样的 HttpClient httpClient=new DefaultHttpClient();4.3是这样的CloseableHttpClient httpClient = HttpCl ...
- 多线程设计模式(三):Master-Worker模式
Master-Worker模式是常用的并行模式之一,它的核心思想是,系统有两个进程协作工作:Master进程,负责接收和分配任务:Worker进程,负责处理子任务.当Worker进程将子任务处理完成后 ...
- docker 及 linux 初接触
3天来净折腾这俩东西了,总结一下(很多都是同事给出的解释,先不保证正确性): 1.docker 里的images 和 container images 类似系统盘,container类似用系统盘装起来 ...
- web deploy 部署网站
一.服务端配置 1. 确保在服务器端(我目前是win server 2012 R2)安装管理服务 安装后服务器会重启, 2)安装webdeploy http://www.iis.net/downloa ...
- Py修行路 python基础 (二十一)logging日志模块 json序列化 正则表达式(re)
一.日志模块 两种配置方式:1.config函数 2.logger #1.config函数 不能输出到屏幕 #2.logger对象 (获取别人的信息,需要两个数据流:文件流和屏幕流需要将数据从两个数据 ...
- MFC 控件使用汇总
一.动态创建button CButton *button=new CButton; button->Create(_T(,,,),);//最后一个是ID BEGIN_MESSAGE_MAP(CM ...
- 真是服了:.EndEdit(); 如果没哟这个一句(c#更新ACCESS,datagridview无法更新第一行)
//保存 this.jbbBindingSource3.EndEdit(); this.jbbTableAdapter3.Update(this.databaseDataSet3.jbb);
- js监听文本框内容变化
js监听文本框内容变化 原理很简单,就是在外部先声明一个用来记录input值的变量,然后每0.1秒比较这个值与input的值,如果发生改变,则运行自己的代码,同时改变变量.从而实现对input值改变的 ...
- 初次用SqlServer查看本地的Excel文件时需要注意的地方
日常用到通过SqlServer 读取Excel文件的案例 ,记录下来 文件路径 :C:\Users\Administrator\Desktop\icd10.xls 1.查询语句: SELECT *F ...