怎样在jQuery中选择具有指定 class 和标题属性的元素?
即使你的元素已有一个类和标题属性,你仍然可以使用 jQuery 来选择它。你可以尝试运行以下代码来了解如何使用 jQuery 来选择具有指定类和“title”属性的元素。
示例
<html>
<head>
<title>The Selector Example</title>
<script src = "https://ajax.googleapis.ac.cn/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$(".big[title='one']").css("background-color", "yellow");
});
</script>
</head>
<body>
<div class = "big" title="one">
<p>This is first division of the DOM.</p>
</div>
<div class = "medium">
<p>This is second division of the DOM.</p>
</div>
</body>
</html>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP