Blogger Information
Blog 39
fans 0
comment 0
visits 34769
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
jquery 常用选择器 4月3日作业
美丽城堡
Original
710 people have browsed it

1、id 选择器

<p id="text">段落</p>

$('#text').css('color','#fff');

2、类选择器

<p class="text">段落</p>

$('.text').css('backgroundColor','skyblue');

3、标签选择器

<p>段落</p>

$('p').css('textAlign','center');

4、后代选择器

<p class="text"><img src="a.png" alt="">段落</p>

$('.text img').css('width',200);

5、子元素选择器

<p class="text">
    <img src="a.png" alt="">
    <p class="content">
        <img src="b.png" alt="">
    </p>
</p>

$('.text > img').css('width',300)

6、属性选择器

<form>
    <input type="text" name="text">
</form>

$('input[name=text]').css("placeholder",'');

7、清除元素上的内联样式 style 属性,删除元素上的属性

$('.text').removeAttr('style')

8、删除元素上的类属性

$('.text').removeClass();
$('.text').removeClass('aa');

9、为元素添加类属性

$('.text').addClass('red');


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post