The [Attribute*=value] Selector usage instance in jquery _jquery

Source: Internet
Author: User

The example in this article describes the [Attribute*=value] selector usage in jquery. Share to everyone for your reference. The specific analysis is as follows:

This selector can match the element for which the given property contains some values.

Syntax structure:

Copy Code code as follows:
$ ("[Attribute*=value]")

Parameter list:

Parameters Describe
Attribute Defines the properties to find.
Value Defines the value to find.
Quotation marks are optional in most cases. However, you avoid conflicts when you encounter such things as property values containing "]".

Instance code:

Example one:

Copy Code code as follows:

<! DOCTYPE html>
<meta charset= "Utf-8" >
<meta name= "Author" co ntent= "http://www.jb51.net/"/>
<title> Cloud Communities </title>
<script type= "Text/javascript" src= " Mytest/jquery/jquery-1.8.3.js "></script>
<script type=" Text/javascript ">
$ (document). Ready (function () {
  $ ("button"). Click (function () {
    $ ("li[id*= ' ir ']"). CSS ("Color", "blue") ;
 })
})
</script>
<body>
<ul>
  <li id= "a" >ht ML zone </li>
  <li id= "second" >jquery zone </li>
</ul>
<ul>
  Li id= "third" > Welcome to Yun-Habitat community </li>
  <li> cloud-Habitat Community welcome you </li>
</ul>
<button> Click See Effects </button>
</body>

The above code sets the text color to blue in the LI element, with an LI element with "IR" in the id attribute value.

Example two:

Copy Code code as follows:

<! DOCTYPE html>
<meta charset= "Utf-8" >
<meta name= "Author" co ntent= "http://www.jb51.net/"/>
<title> Cloud Communities </title>
<script type= "Text/javascript" src= " Mytest/jquery/jquery-1.8.3.js "></script>
<script type=" Text/javascript ">
$ (document). Ready (function () {
  $ ("button"). Click (function () {
    $ ("Li[id*=[ir]"). CSS ("Color", "blue");
 })
})
</script>
<body>
<ul>
  <li id= "F[irst" >h tml Zone </li>
  <li id= "second" >jquery zone </li>
</ul>
<ul>
  &L T;li id= "Third" > Welcome to Yun-Habitat community </li>
  <li> cloud-Habitat Community welcome you </li>
</ul>
<button> Click View effects </button>
</body>

From the above code you can see how the code contains "[" or "]", you must enclose quotes, or you will cause a matching error.

I hope this article will help you with your jquery programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.