zoukankan      html  css  js  c++  java
  • 总结5.6 jsDOM操作2

            /*失去焦点*/
            document.getElementById('input').onblur = function(){
                console.log('失去焦点');
            }//鼠标到input文本框外时,控制台显示失去焦点
            /*获取焦点*/
            document.getElementById('input').onfocus = function() {
                console.log('获取焦点');
            }//鼠标在input文本框内时,控制台显示获取焦点
            /*添加元素*/
            var p = document.createElement('p');//创建新元素类型
            var nod = document.createTextNode('新段落');//创建新元素内容
            p.appendChild(nod);//形成添加的新元素
            document.getElementById("ids").appendChild(p);//将元素添加进对象
            /*删除元素*/
            var parent = document.getElementById('id');//找到父元素
            var child = document.getElementsByName('p');//找到父元素中需要删除的元素
            parent.removechild(child);//删除元素
            /*替换元素*/
            var para = document.createElement('div');
            var nod1 = document.createTextNode('新段落一');
            div.appendChild(nod1);//与添加元素时创建新元素一样
            var parent = document.getElementById('id');
            var child = document.getElementsByName('p');//找到父元素中需要替换的元素
            parent.replacechild(child);
            var y = setInterval(function(i){
                i++;
            },2000);//定时器,2000代表每2000ms执行一次函数
            document.getElementById('id').onclick = function(){
                clearInterval(y);
            }//取消定时器
            var z = setTimeout(function(j){
                j--;
            },2000);//延时器,执行跟定时器类似,但是只在规定时间后执行一次
            document.getElementById('id').onclick = function(){
                clearTimeout(z);
            }//取消延时器
            document.getElementById('id').onclick = function(){
                window.location.href = 'http://www.baidu.com';
            }//点击id元素时,跳转到百度界面
            document.getElementById('id1').onclick = function(){
                window.history.back();
            }//点击id1元素时,后退到上个界面
            document.getElementById('id2').onclick = function(){
                window.onload = function(z) {
                    z++;
                }
            }//当元素id2加载完后,执行内部function
  • 相关阅读:
    mybatis整合redis二级缓存
    python字符串非空判断
    mybatis源码分析之05一级缓存
    mybatis框架之动态代理
    Redis事件通知示例
    springboot2集成redis5报错:io.lettuce.core.RedisException: io.lettuce.core.RedisConnectionException: DENIED Redis is running in protected
    Centos7关闭防火墙
    mybatis源码分析之04Mapper接口的动态代理
    mybatis源码分析之03SqlSession的创建
    mybatis源码分析之02配置文件解析
  • 原文地址:https://www.cnblogs.com/HighKK/p/12837018.html
Copyright © 2011-2022 走看看