jQuery how to select ID elements starting with specific characters

coldplay.xixi
Release: 2020-11-26 14:29:55
Original
2745 people have browsed it

How jQuery selects ID elements starting with specific characters: Use jquery’s [[attribute=value]] selector to achieve this. The [[attribute=value]] selector selects each element with the specified attribute and Element starting with the specified string.

jQuery how to select ID elements starting with specific characters

  • This method applies to all brands of computers

jQuery selects a specific Methods for ID elements starting with characters:

If you want to use jQuery to select elements whose ID starts with a specific character, you can use jquery's [attribute=value] selector.[attribute=value]The selector selects every element with the specified attribute and starting with the specified string.

Syntax:

$("[attribute^='value']")
Copy after login

Let’s take a look at the use of[attribute^=value]selector through examples.

Example: Select the element whose id starts with "demo" and change its background color

      
这是div盒。

Copy after login

Output:

jQuery how to select ID elements starting with specific characters

Related Free learning recommendations:javascript(video)

The above is the detailed content of jQuery how to select ID elements starting with specific characters. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!