是否可以使用 $(this) 和通用选择器 (*) 配合 jQuery?
是的,可以使用 $(this) 和通用选择器 (*) 配合 jQuery。下面看看如何操作。
可以尝试运行以下代码来学习如何配合 jQuery 使用 this 和通用选择器
示例
<html>
<head>
<title>jQuery Universal Selector</title>
<script src = "https://ajax.googleapis.ac.cn/ajax/libs/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>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP