The three jQuery selectors below all have the same result. What is the difference?
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<p><span>Hello</span>, how are you?</p>
<p>Me? I'm <span>good</span>.</p>
<script>
$('p > span').css('color','red');
OR
$('span', 'p').css('color','red');
OR
$('p span').css('color','red');
</script>
</body>
</html>
$('span', 'p')and$('p span')are identical, both will select any span elements that are descendants of any p element no matter the depth.$('p > span')on the other hand will select span elements that are direct children of the p element. So for example this selector would not select the span element in the following example:..whereas the other two would select it just fine.