• 今日总结


    2020年9月20日:

     事件

    页面载入

    1
    2
    ready(fn)  // 当DOM载入就绪可以查询及操纵时绑定一个要执行的函数。
    $(document).ready(function(){}) -----------> $(function(){})  

    事件绑定

    //语法:  标签对象.事件(函数)    
    eg: $("p").click(function(){})
    复制代码
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
    </ul>
    <hr>
    <button id="add_li">Add_li</button>
    <button id="off">off</button>
    
    <script src="jquery.min.js"></script>
    <script>
        $("ul li").click(function(){
            alert(123)
        });
    
        $("#add_li").click(function(){
            var $ele=$("<li>");
            $ele.text(Math.round(Math.random()*10));
            $("ul").append($ele)
    
        });
    
    
    //    $("ul").on("click","li",function(){
    //        alert(456)
    //    })
    
         $("#off").click(function(){
             $("ul li").off()
         })
        
    </script>
    复制代码

    属性操作

    复制代码
    --------------------------CSS类
    $("").addClass(class|fn)
    $("").removeClass([class|fn])
    --------------------------属性 $("").attr(); $("").removeAttr(); $("").prop(); $("").removeProp();
    --------------------------HTML代码/文本/值 $("").html([val|fn]) $("").text([val|fn]) $("").val([val|fn|arr])
    --------------------------- $("#c1").css({"color":"red","fontSize":"35px"})
    复制代码

    文档节点处理

    复制代码
    //创建一个标签对象
        $("<p>")
    
    
    //内部插入
    
        $("").append(content|fn)      ----->$("p").append("<b>Hello</b>");
        $("").appendTo(content)       ----->$("p").appendTo("div");
        $("").prepend(content|fn)     ----->$("p").prepend("<b>Hello</b>");
        $("").prependTo(content)      ----->$("p").prependTo("#foo");
    
    //外部插入
    
        $("").after(content|fn)       ----->$("p").after("<b>Hello</b>");
        $("").before(content|fn)      ----->$("p").before("<b>Hello</b>");
        $("").insertAfter(content)    ----->$("p").insertAfter("#foo");
        $("").insertBefore(content)   ----->$("p").insertBefore("#foo");
    
    //替换
        $("").replaceWith(content|fn) ----->$("p").replaceWith("<b>Paragraph. </b>");
    
    //删除
    
        $("").empty()
        $("").remove([expr])
    
    //复制
    
        $("").clone([Even[,deepEven]])
    复制代码

    css操作

            $("").offset([coordinates])
            $("").position()
            $("").scrollTop([val])
            $("").scrollLeft([val])

    尺寸操作

            $("").height([val|fn])
            $("").width([val|fn])
            $("").innerHeight()
            $("").innerWidth()
            $("").outerHeight([soptions])
            $("").outerWidth([options])
  • 相关阅读:
    google 语音识别返回,
    如果到来,会是怎样情况,fuck,
    sql
    阅读《一》
    阅读,
    Codevs 1078 ==Poj 1258 Agri-Net
    洛谷 P3399 丝绸之路
    线段树-代码实现细节与技巧
    Codevs 1371 浴火银河跑运输
    POJ 3267 The Cow Lexicon
  • 原文地址:https://www.cnblogs.com/yitiaokuailedexiaojingyu/p/14094040.html
Copyright © 2020-2023  润新知