jq

1.jq change()事件

当元素值发生改变时,会发生change事件,该事件只适合于文本域,textarea以及select。

当适用于select元素时,change事件会在选择某个选项时发生,当适用于text或textarea时,change事件会在文本域失去焦点的时候触发

2.jq ajax()方法

jq代码:

$(function(){
        $(".box").click(function(){
            htmlobj=$.ajax({url:"test.txt",async:false});
            $("p").html(htmlobj.responseText);
        }) ;
})

html代码

<div class="box">click me</div>    
<p></p>

test.txt的编码格式要和html一样,不然会乱码,可以在另存为的时候设置编码。

async:Boolean值,true为异步请求,false为同步请求,默认情况下为异步请求。

注意:同步请求将锁住浏览器,用户其它操作必须等待请求完成才可以执行。

3.height() - height;

   innerHeight()-height+padding

   outerHeight()-height+padding+border

   outerHeight(true)-height+padding+border+margin

参数设置为true才能算上margin的值

4.获得当前元素的名称this.nodeName;

$("p").bind("dblclick", function(){
$("span").text("Double-click happened in " + this.nodeName);
});
原文地址:https://www.cnblogs.com/theEndOfSummer/p/4500257.html