1. 程式人生 > >選擇器修改樣式

選擇器修改樣式

true left dcl bounce button rop 修改 子元素 mat

addClass和removeClass

eg:

$("button").addClass("animated bounce");

$(".well").addClass("animated shake");

$("#target3").addClass("animated fadeOut");

$("button").removeClass("btn-default");

修改css:

$("#target1").css("color","red");

修改html元素屬性:

$("#target1").prop("disabled",true);

修改元素內部的html和文本內容:html和text

$("#target4").html("<em>jQuery Playground</em>");

$("#target3").text("hello target");

刪除元素:remove

$("#target4").remove();

appendTo:

$("#target2").appendTo("#right-well"); //Move your target2 element from yourleft-well to your right-well. 用appendTo會刪除原來位置的元素

clone():

$("#target5").clone().appendTo("#left-well");//Clone your target5 element and append it to your left-well.clone 會保持原來的元素,在其原來的位置

parent():選擇父元素

children():選擇所有的子元素

選擇特定的某個元素:

$(".well:nth-child(2)").addClass("animated bounce");

選擇器修改樣式