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
- Course Recommendations
- Courseware download
-
IntermediateFront-end Vue3 actual combat [handwritten vue project]
2857 people are watching -
ElementaryAPIPOST tutorial [Popularization of technical concepts related to network communication]
1795 people are watching -
IntermediateIssue 22_Comprehensive actual combat
5521 people are watching -
ElementaryIssue 22_PHP Programming
5172 people are watching -
ElementaryIssue 22_Front-end development
8713 people are watching -
IntermediateBig data (MySQL) video tutorial full version
4525 people are watching -
ElementaryGo language tutorial-full of practical information and no nonsense
2794 people are watching -
ElementaryGO Language Core Programming Course
2814 people are watching -
IntermediateJS advanced and BootStrap learning
2563 people are watching -
IntermediateSQL optimization and troubleshooting (MySQL version)
3374 people are watching -
IntermediateRedis+MySQL database interview tutorial
2963 people are watching -
ElementaryDeliver food or learn programming?
5708 people are watching - Let's briefly talk about starting a business in PHP
- Quick introduction to web front-end development
- Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
- Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
- Login verification and classic message board
- Computer network knowledge collection
- Quick Start Node.JS Full Version
- The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
- Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
- About us Disclaimer Sitemap
- php.cn:Public welfare online PHP training,Help PHP learners grow quickly!
$("[href]" ) Select element with href attribute
$ ("a [target = '_lank']") Select all target attribute values equal to "_blank" & lt; a & gt; element
## $ ( "a[target!='_blank']") Select all elements whose target attribute value is not equal to "_blank" $(":button") Select all< of type="button" Input & gt; element and & lt; button & gt; element $ ("tr: event") Select the even position of & lt; tr & gt $ ("tr: ODD"). TheUsing jQuery functions in standalone files
If your website contains many pages and you want your jQuery functions to be easy to maintain, then please Put your jQuery functions into separate .js files.
When we demonstrate jQuery in the tutorial, we add the function directly into the section. However, it would be better to put them in a separate file, like this (referencing the file via the src attribute):Continuing Learning
Students who have watched this course are also learning