js

DOM对象

  windows:属性:opener(打开者)

          方法:open()、close(),setTimeout()、setInterval()...

   location:属性:href

        方法:reload()刷新

   history:方法:go()

   status:不常用

   document:下面详细介绍

JS对document对像的操作

  分两个: 找到对象、操作对象。

  找到对象的方法:document.getElementById()、document.getElementsByName()、

          document.getElementsByTagName(),//通过元素名找到结果是数组,elements加s了

          document.getElementsByClassName()

    PS:this关键字的用法,指这条元素,省去了document.的方法找元素了

      例如给按钮创建单击事件 onclick="doout(this)"  方法:function dout(tx){tx.属性等}

  操作对象:包括:

    操作属性:取值:getAttribute,赋值:setAttribute,删除属性:remoeAttribute

    操作样式:内联样式:style.xxxx

          class:1、className

              2、把class当成属性来看

     操作内容:表单元素:value

          非表单元素:1、innerHTML

                2、innerText

    操作元素:操作整个元素:创建(字符串、createElement())、添加子元素(appendChild())、删除(remover())、复制(clonNode())

          操作相关元素:前后、父、子

 js判断字符串是否为空

s 匹配任何空白字符,包括空格、制表符、换页符等等。等价于 [ fnrtv]。 很多情况下,都是用length来直接判断字符串是否为空,如下:
代码如下 :
var strings = ' ';
if (strings.replace(/(^s*)|(s*$)/g, "").length ==0)
{
alert('不能为空');
}

posted on 2016-06-16 08:26  。。小兵  阅读(109)  评论(0编辑  收藏  举报