1 hide 按钮隐藏
. class p.class p#xxx
("[href$='.jpg']") 选取所有 href 值以 ".jpg" 结尾的元素。
2 css $("p").css("background-color","red");
hide("slow")
show
("p").toggle();
(selector).fadeOut(speed,callback);
(selector).fadeTo(speed,opacity,callback);
3\
(selector).slideUp(speed,callback); $(selector).slideToggle(speed,callback);
4 animate
("button").click(function(){
("button").click(function(){
("button").click(function(){ $("div").animate({ left:'250px', height:'+=150px', width:'+=150px' }); });
callback $("p").hide(1000,function(){ alert("The paragraph is now hidden"); });
链式写法 $("#p1").css("color","red").slideUp(2000).slideDown(2000);
text() html() val() attr("href")
更改属性:
("#w3s").attr({ "href" : "http://www.w3school.com.cn/jquery", "title" : "W3School jQuery Tutorial" }); });
("p").prepend("Some prepended text.");
("img").before("Some text before");
("#div1").empty(); $("p").remove(".italic");
("h1,h2,p").removeClass("blue"); });
("h1,h2,p").toggleClass("blue"); });
("h1,h2,p").addClass("blue"); $("div").addClass("important"); });
("p").css("background-color","yellow");
("button").click(function(){ var txt=""; txt+="Width: " +
("#div1").height(); $("#div1").html(txt); });
("#div1").innerWidth() + "</br>"; txt+="Inner height: " +
("#div1").html(txt); });
("#div1").outerWidth() + "</br>"; txt+="Outer height: " +
("#div1").html(txt); });
$("span").parent();
("span").parents("ul"); $("span").parentsUntil("div");
$("div").children();
("div").find("span"); $("div").find("*");
("h2").next();
("h2").nextUntil("h6"); jQuery prev(), prevAll() & prevUntil() 方法
("div p").last();
("p").not(".intro");