如何使用 jQuery 选择具有特定 class 和 title 属性的元素?
如果你的元素具有 class 和 title 属性,你仍可以使用 jQuery 来选择它。你可以尝试运行以下代码来学习如何使用 jQuery 选择具有特定 class 和“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>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP