jquery hierarchical selector problem I tested and found out why there is no difference between ul>li and ul li?
虎哥
虎哥 2019-02-06 19:00:47
0
3
1215

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>Document</title>

<script type="text/javascript" src="jquery/jquery-3.3.1.min.js"></script>

</head>

<body>

<script>

$(document).ready(function(){

// $('ul>li').css('list-style','none')

$('ul li').css('list-style','none')

// $('label input').css('height','100px')

// $('input button').css('height','100px')

$('label~input').css('background','pink')

})

</script>

<ul>

<li>1</li>

<li>1

<li>2</li>

</li>

<li>1

<div>

<li>3

<li>4

<ul>

<li>5</li>

</ul>

</li>

</li>

</div>

</li>

<li>1</li>

<li>1</li>

</ul>

<form action="">

<label for="">姓名</label>

<input type="text"><button>按钮</button><br>

<input type="text"><button>按钮</button><br>

<input type="text"><button>按钮</button><br>

<input type="text"><button>按钮</button><br>

<input type="text"><button>按钮</button><br>

</form>

</body>

</html>


虎哥
虎哥

reply all(2)
粽叶飘香

ul>li Only search for son elements, except for son elements, other elements are not found.

ul li Search for all elements

灭绝师太

ul>li: Find the li that is the direct child element of ul
ul li: Find all the li below ul


##

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template