CSS Selectors Cheat Sheet and jQuery Selectors

1. CSS Simple Selectors

Tag Selector

ID Selector

Class Selector

Grouping the CSS Selectors

p, h1, #my_id, .style {
       font-weight: bold;
       text-decoration: underline;
}

Universal Selector

*

Specific Class Selector

h1.my_class

2. CSS Combinator Selectors

Descendant Selector

div p

Child Selector

div > h3

Adjacent Sibling Selector

div + h3

General Sibling Selector

div ~ h3

3. CSS Pseudo-Class Selectors

a:link

a:visited

a:hover

:hover

:active

:checked

4. CSS Pseudo Element Selectors

::first-line

::first-letter

::before

::after

li::marker

::selection

5. CSS Attribute Selectors

p[lang]

p[lang = "hi"]

6. jQuery Basic Selectors

7. jQuery Basic Filter Selectors

 elements, zero-indexed. elements, zero-indexed.
:first $("p:first") Selects the first 

 element.

:last $("p:last") Selects the last 

 element.

:even $("tr:even") Selects all even 
:odd $("tr:odd") Selects all odd 

8. jQuery Child Filter Selectors

:first-child $("p:first-child") Selects all 

 elements that are the first child of their parent.

9. jQuery Content Filter Selectors

:contains() $('p:contains("Hello")') Selects all 

 elements that contains the text "Hello".

10. jQuery Form Selectors

:radio $(":radio") Selects all input elements with type="radio".
:checkbox $(":checkbox") Selects all input elements with type="checkbox".

11. jQuery Attribute Selectors

12. jQuery Hierarchy Selectors

Selector Example Description
parent > child $("ul > li") Selects all 
  •  elements that are direct child of their parent 
       element.
  • ancestor descendant $("form label") Selects all  elements that are descendant of their ancestor 
     element.
    prev + next $("h1 + p") Selects all 

     elements that are next i.e. immediately preceded to the 

     elements.

    prev ~ siblings $("h1 ~ p") Selects all 

     elements that are siblings and follow after the 

     elements.

    13. jQuery Visibility Filter Selectors

    References

    The Ultimate CSS Selectors Cheat Sheet You Must Know (lambdatest.com)https://www.lambdatest.com/blog/css-selectors-cheat-sheet/

    Complete List of jQuery Selectors - Tutorial Republichttps://www.tutorialrepublic.com/jquery-reference/jquery-selectors.php

    
    
    
        
        a
        
        
    
    
    

    子元素

    子元素

    jQuery是一个快速、简洁的JavaScript框架,是继Prototype之后又一个优秀的JavaScript代码库(框架)于 2006年1月由John Resig发布。jQuery设计的宗旨是“write Less,Do More”,即倡导写更少的代码,做更 多的事情。它封装JavaScript常用的功能代码,提供一种简便的JavaScript设计模式,优化HTML文档操作、事件 处理、动画设计和Ajax交互。

    jQuery的核心特性可以总结为:具有独特的链式语法和短小清晰的多功能接口;具有高效灵活的CSS选择器,并且可 对CSS选择器进行扩展;拥有便捷的插件扩展机制和丰富的插件。jQuery兼容各种主流浏览器,如IE 6.0+、FF 1.5+、 Safari 2.0+、Opera 9.0+等。

    子元素

    子元素

    你可能感兴趣的:(Web,Front-end,css,前端)