jquery 方法 还记得吗?

2017-07-14  本文已影响13人  butterflyer
class    用.
id  用 #
$("button")
$(".button")
$("#button")
$("div p")
$("div.p")
$("div#p")   
$("#test").val()
$("#test").html()
$("#test").text()

$("#btn1").click(function(){
  $("#test1").text("Hello world!");
});
$("#btn2").click(function(){
  $("#test2").html("<b>Hello world!</b>");
});
$("#btn3").click(function(){
  $("#test3").val("Dolly Duck");
});

$(".test").attr("href","http://www.baidu.com")
 $("#w3s").attr({
    "href" : "http://www.w3school.com.cn/jquery",
    "title" : "W3School jQuery Tutorial"
  });
$("p").append("some");
$("p").prepend("some");

$("<p></p>").test('test.');
<p>test1</p>
document.createElement("p").innerHTML="text.";

$("img").after("some");
$("img").before("some");
$("#div1").remove()
$("#div1").remove("p");
$("#div1").empty();

.blue{
color:blue;
}
.mylove{
font-size:100px;
}
$("h1").addClass("blue");
$("h1").addClass("mylove blue");
$("h1").removeClass("blue");
$("h1").toggleClass("blue");
$("p").css("color");
$("p").css("color","blue");
$("p").css({"color":"blue","font":"100"});
$("p").width();
$("p").height();
$("p").innerWidth();
$("p").innerHeight();
$("p").outerWidth();
$("p").outerHeight();
$("p").width(100).height(100);
$("div").parent();
$("div").parents();
$("div").parents("ul");
$("div").parentsUntil();
$("span").parentsUntil("div");
$("div").children();
$("div").children("p.1");
$("div").find("span");
$("div").find("*");
$("div").siblings();
$("div").siblings("p");
$("div").next();
$("div").nextAll();
$("div").nextAll("h1");
$("div").nextUnit("h5");
prev()  prevAll()  prevUntill()

$("div p").first();
$("div p").last();
$("p").eq(1);
$("p").filter(".num");
$("p").filter("#num");
$("p").not(".num");
上一篇下一篇

猜你喜欢

热点阅读