jQuery学习笔记

jQuery


Selector
$("#").
$(".").
$("[]").


Event
.click(function{

})


.mouseover(function{

})






var jq = jQuery.noconflict()


.hide()
.show()
.toggle()


.fadeIn()
.fadeOut()
.fadeToggle()
.fadeTo()


.slideDown()
.slideUp()
.slideToggle()


.animate({})
.stop()


.css()


.text()
.html()
.val()


.attr("href")


$("#").html(function(i, text){
return "" + text + "";
});


.append
.prepend
.after
.before


//<img>和<br>单标签只能用.after和.before


<script>
function appendText()
{
var txt1 = "<p>Text.</p>";
var txt2 = $("<p></p>").text("Text.");
var txt3 = document.createElement("p");
txt3.innerHTML = "Text.";
$("body").append(txt1, txt2, txt3);
}
</scirpt>


.remove()
.empty()
.remove(".")
//remove删除被选元素及其子元素
//empty清空子元素


.addClass()
.removeClass()
.toggleClass()
.css()


<style>
.blue{

}
</style>


.addclass("blue")


.width()
.height()
.innerWidth()
.innerHeight()
.outerWidth()
.outerHeight()


$(document).width()
$(window).width()


.parent()
.parents()
.parentsUntil("div")
.parent("ul")


.children()
.children("p.1")
.find("span")
.find("*")


.siblings()
.siblings("p")
.next()
.nextAll()
.nextUntil("h6")
.prev()
.prevAll()
.preUntil("")


$("div p").first().css()
$("div p").last().css()
$("p").eq(1).css()
$("p").filter(".intro").css()
$("p").not(".intro").css()


$(selector).load(URL, data, callback)


$("#div1").load("demo_test.txt")
$("#div1").load("demo_test.txt #p1")


callback
responseTXT, statusTXT, xhr


$("#div1").load("demo_test.txt", function(responseTxt, statusTxt, xhr)){
if (statusTxt == "success")
;
if (statusTxt == 'error')
alert("Error: "+ xhr.status + ": " + xhr.statusText);
}


//HTTP请求


$.get
$.post
$.get(URL, callback)
$.post(URL, data, callback)


$("button").click(function(){
$.post("demo.asp",
{
name: "",
city: ""
})
function(data, status){
alert("Data: " + data + "\nStatus: " + status);
}
})




$.noConflict()
jQuery(document).ready(function(){
jQuery("button").click(function(){


})
})


$.noConflict()
jQuery(document).ready(function($){
$("button").click(function(){


})
})


//函数内使用 $ 符号 - 而在函数外,依旧不得不使用"jQuery"


$(this).hide()


$(document).ready(function(){
$("button").click(function(){
$(this).hide();
})
})


.css()
.offset()
.offset().left
.offset().right


//偏移


.position()
.position().left
.position().top


//相对于父元素位置


.hasClass("intro")


//true 


//post
.size()


//event


$("button").bind("click": function(){
$("p").slideToggle();
})


.mouseover(function(){

})
.mouseout(function(){

})
.mouseenter(function{

})
.mouseleave(function{

})


//不论鼠标指针穿过被选元素或其子元素,都会触发mouseover
//只有在鼠标指针穿过被选元素时,才会触发mouseenter

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值