自定义动画 load Dom普通属性读写

85 阅读1分钟

自定义动画

自定义动画:animate,可以对offset相关属性设置动画效果
dom.animate({配置信息},[时间间隔],[过渡效果],[异步函数])

load

功能:将服务器文件响应的内容,赋值给jQuerydom元素的html
参数:jQuerydom.load(url,[请求参数],[回调函数])
    $("#box").load("3.load.txt");
​
作用:对于页面的头尾,进行分离
    load通常请求的服务器文件只为html文件,所以也不发请求参数,
当发送求情参数时,用post
不发送求参数时,用get
​
    $("header").load("3.header.html",function(){
        $("li").click(function(){
            console.log($(this).html());
        });
    });    
    $("header").load("3.header.html");

get

参数:$.get("url",请求参数,回调函数)
    function([resText],[status],[xhr]){
    }
返回值:promise对象
    urlencoded,键值对
 $.getScript(url,回调函数)

Dom普通属性读写

attr/prop

读 console.log(("#box").attr("id")); 写 ("#box").attr("id","heihei"); 添加自定义属性 attr ("#box").attr("a","123"); ("#box").attr({ a:1, b:2, c:3 }); console.log(("input[type=checkbox]").attr("checked"));propconsole.log(("input[type=checkbox]").attr("checked")); prop console.log(("input[type=checkbox]").prop("checked"));

DomStyle属性当读写  css
写
    $("#box").css({
        width:"100px",
        height:200,
        backgroundColor:"red",
        fontSize:36,
        opacity:0.3
    });
 读
    console.log($("#box").css("opacity"));
    console.log($("#box").css(["opacity","fontSize"]));
    console.log($("#box").css("width"));
Domoffset相关属性 
width,height
读
    console.log($("#box").width());
    console.log($("#box").height());
写
    $("#box").width(200);
    $("#box").height(300);
left和top
    //offset:自带绝对定位
写
    $("#box").offset({
        left:500,
        top:200
    });
读
    console.log($("#box").offset().left);
    console.log($("#box").offset().top);