jQuery selector

jQuery Selectors

jQuery selectors allow you to operate on groups of HTML elements or individual elements.

jQuery Selectors

jQuery selectors allow you to operate on groups of HTML elements or individual elements.

jQuery selectors "find" (or select) HTML elements based on the element's id, class, type, attributes, attribute values, etc. It is based on existing CSS selectors, in addition to some custom selectors.

All selectors in jQuery begin with a dollar sign: $().

Element Selector

jQuery element selector selects elements based on their name.

Select all

elements in the page:

$("p")

Example

After the user clicks the button, all< p> All elements are hidden:

    jQuery示例   

这是一个标题

这是一个段落。

这是另一个段落。

#id selector

jQuery #id selector selects the specified element through the id attribute of the HTML element .

The id of the element in the page should be unique, so if you want to select the only element in the page, you need to use the #id selector.

The syntax for selecting elements by id is as follows:

$("#test")

      

好好学习

天天向上

PHP测试

.class selector

The jQuery class selector can find elements by specifying the class.

The syntax is as follows:

$(".test")

GrammarDescription

$("*") Select all elements Select the

whose class is intro Elements

$("p:first") Selects the first

element li> element

$("ul li:first-child") Selects the first

  • element of each
  • Continuing Learning
    ||

    你马上就看不见我了

    你就要看不见我了

    为什么还能看见我

    submit Reset Code
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!