选择器修改样式

Posted yyy_鸳鸯

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了选择器修改样式相关的知识,希望对你有一定的参考价值。

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");

 

以上是关于选择器修改样式的主要内容,如果未能解决你的问题,请参考以下文章

基于Vue和Element-UI中Select 选择器的分组全选以及样式修改问题

选择器高级样式及布局

element - 组件样式修改 (在间选择器上移动时 对应的时分秒增加背景色)

深度选择器

高手请进!关于CSS中class选择器使用多种样式的问题

Web开发·期末不挂之第四章·CSS语法基础(CSS选择器&选择器优先级&各类样式表的使用方法)