是的,可以在jQuery中使用$(this)和通用选择器(*)。让我们看看如何做。
您可以尝试运行以下代码,以了解如何在jQuery中使用此 和通用选择器:
<html>
<head>
<title>jQuery Universal Selector</title>
<script src = "https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('*', this).css("background-color", "yellow");
});
</script>
</head>
<body>
<div class = "demo1" id = "div1">
<p>This is first division of the DOM.</p>
</div>
<div class = "demo2" id = "div2">
<p>This is second division of the DOM.</p>
</div>
</body>
</html>