Home
Web Front-end
JS Tutorial
Usage examples and precautions when the selector contains spaces_jquery



Usage examples and precautions when the selector contains spaces_jquery
May 16, 2016 pm 05:27 PM
space
Selector
Principle explanation:
var $t_a=$(".test :hidden") //The space indicates that the class is selected as the hidden element in test;
var $t_a =$(".test:hidden")//Without spaces, it means selecting hidden elements with class test;
Example:
<html>
<head>
<script type=" text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function (){
var $a1=$(".test :hidden");
var $a2=$(".test:hidden");
alert($a1.length " " $a2 .length)
})
</script>
<style>
</style>
</head>
<body>
< ;div class="test" style="display:none;">
<p style="display:none">dddddddd</p>
<p style="display:none" >dddddddd</p>
</div>
<div class="test" style="display:none">
</div><div class="test " style="display:none"></div>
<body>
</html>
The output results are: 2 and 3 respectively;
var $t_a=$(".test :hidden") //The space indicates that the class is selected as the hidden element in test;
var $t_a =$(".test:hidden")//Without spaces, it means selecting hidden elements with class test;
Example:
Copy code The code is as follows:
<html>
<head>
<script type=" text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function (){
var $a1=$(".test :hidden");
var $a2=$(".test:hidden");
alert($a1.length " " $a2 .length)
})
</script>
<style>
</style>
</head>
<body>
< ;div class="test" style="display:none;">
<p style="display:none">dddddddd</p>
<p style="display:none" >dddddddd</p>
</div>
<div class="test" style="display:none">
</div><div class="test " style="display:none"></div>
<body>
</html>
The output results are: 2 and 3 respectively;
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

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The difference between full-width spaces and half-width spaces

Use the :nth-child(n+3) pseudo-class selector to select the style of child elements whose position is greater than or equal to 3

What is the difference between full-width spaces and half-width spaces?

From beginner to proficient: Master the skills of using is and where selectors

What to do if the javascript selector fails

Sharing of practical techniques for replacing spaces in Golang
