Home > Web Front-end > JS Tutorial > Example of usage of [attribute*=value] selector in jQuery_jquery

Example of usage of [attribute*=value] selector in jQuery_jquery

WBOY
Release: 2016-05-16 16:22:46
Original
1005 people have browsed it

The example in this article describes the usage of the [attribute*=value] selector in jQuery. Share it with everyone for your reference. The specific analysis is as follows:

This selector matches elements containing certain values ​​for a given attribute.

Grammar structure:

Copy code The code is as follows:
$("[attribute*=value]")

Parameter list:

参数 描述
attribute 定义要查找的属性。
value 定义要查找的值。
引号在大多数情况下是可选的。但在遇到诸如属性值包含"]"时,用以避免冲突。

Example code:

Example 1:

Copy code The code is as follows:






Script Home





  • html area

  • Jquery area



  • Welcome to the Script House

  • Script House welcomes you





The above code can set the text color of the li element with "ir" in the id attribute value to blue.

Example 2:

Copy code The code is as follows:






Script Home





  • html area

  • Jquery area



  • Welcome to the Script House

  • Script House welcomes you





From the above code, you can see how when the code contains "[" or "]", it must be enclosed in quotation marks, otherwise it will cause a matching error.

I hope this article will be helpful to everyone’s jQuery programming.

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template