• javascript语句语义大全(7)


    1. 弹窗

    open('案例:广告弹窗窗+自动关闭.html','','width=400,height=400,top=200,left=200,toolbar=no');

    对应的:

    close();

    关闭窗口

    2. 滚轮

    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;

    代表滚轮,可以设置到达一定高度后出现某种效果

    3. 属性设置

    _oDiv.index=0;

    _oDiv.setAttribute('a','a1');//属性名,属性值;设置

    4. 节点相关

    var _oUl=document.getElementById('oUl')
    console.log(_oUl.childNodes)//获得ul的子节点
    console.log(_oUl.childNodes.length)//获得ul的子节点长度
    console.log(_oUl.firstChild)//获得当前元素的第一个子节点
    console.log(_oUl.lastChild)//获得当前元素的最后一个子节点
    console.log(_oUl.parentNode)//获得当前元素的父节点
    console.log(_oUl.lastChild.previousSibling)//previousSibling前一个同级节点
    console.log(_oUl.firstChild.nextSibling)//nextSibling后一个同级节点

    alert(_oUl.ownerDocument.body.innerHTML)//根节点

    console.log(_liA.nodeName)//获得元素的标签名称
    console.log(_liA.firstChild.nodeValue)//获得节点的值
    console.log(_liA.nodeType)//节点类型
    _liA.firstChild.nodeValue='<b>xx</b>'
    _liA.innerHTML='<b>xx</b>'

    var node=document.createElement('a')//创建元素节点
    node.innerHTML='link'
    node.href='http://www.baidu.com'
    _liA.appendChild(node)//把node节点添加到_liA节点内

    var node=document.createElement('li')
    node.innerHTML='新的li节点'
    var _liB = _oUl.childNodes[3];
    _oUl.insertBefore(node, _liB)//在_oUl里面,把node插入到_liB的前面

    _oUl.removeChild(_liA)//移除节点 

    5. 属性

    console.log(_oUl.attributes);//获取当前元素节点的所有属性节点集合

    console.log(_oUl.attributes.length)//长度
    console.log(_oUl.attributes.index);
    _oUl.attributes.index.value = 1
    console.log(_oUl.attributes.index.value);
    console.log(_oUl.attributes['index'])
    console.log(_oUl.attributes.getNamedItem('id').value)
    console.log(_oUl.id)
    console.log(_oUl.attributes[0])
    console.log(_oUl.attributes[0].nodeType)//元素1 属性2 文本3
    console.log(_oUl.attributes[0].nodeValue)

  • 相关阅读:
    ASP.NET Forums 2.0 修改集锦(一)
    在自己的应用程序中显示Windows关于对话框
    ASP.NET Forums 2.0 本地化修改(四)
    Flash对双字节的支持问题
    DotNetNuke 2.1.2安装指南
    ASP.NET Forums 2.0 本地化修改(五) 增加页面Meta标记的keywords和description
    ASP.NET Forums 2.0 本地化修改(三)
    JavaScript利用正则表达式自己写数字判断函数
    hash表基础知识(转载)
    求子数组的最大和
  • 原文地址:https://www.cnblogs.com/thestudy/p/5621391.html
Copyright © 2020-2023  润新知