Home > Web Front-end > JS Tutorial > What is jquery not equal to attribute selector

What is jquery not equal to attribute selector

藏色散人
Release: 2023-01-04 09:37:16
Original
3451 people have browsed it

jquery is not equal to the attribute selector refers to the "[attribute!=value]" selector, which is used to select all elements where the specified attribute does not exist or the specified attribute value is not equal to a certain value.

What is jquery not equal to attribute selector

The operating environment of this article: windows10 system, jquery 1.11.1, thinkpad t480 computer.

Recommended: "jquery Video Tutorial"

jquery attribute is not equal to the selector is the [attribute!=value] selector; used to select all specified attributes that do not exist or All elements whose specified attribute value is not equal to a certain value.

The selector treats the attribute value as an ordinary string (this is different from the class selector). For example, $('a[rel!=nofollow]') will match Some text.

The following code shows how to get all elements whose ID is not equal to cheese.

<!DOCTYPE html> 
<html>
    <head>
        <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
    </head> 
    <body>
        <div id="eggs"></div> 
        <div id="ham"></div> 
        <div id="cheese"></div> 
        <script>
            var n = $("[id!=&#39;cheese&#39;]").length; 
            alert(n);
        </script> 
    </body> 
</html>
Copy after login

The following code selects all input box elements whose input names are not me.

<html>
  <head>
    <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
          $("input[name!=&#39;me&#39;]").next().text(" changed");
    });
    </script>
  </head>
  <body>
      <div>
        <input type="radio" name="you" value="A" />
        <span>data</span>
      </div>
      <div>
        <input type="radio" name="me" value="B" />
          <span>data</span>
      </div>
      <div>
        <input type="radio" name="me" value="C" />
        <span>data</span>
      </div>
  </body>
</html>
Copy after login

The above is the detailed content of What is jquery not equal to attribute selector. 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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template