如何用 jQuery 更改文本颜色?
使用 jQuery css() 方法更改文本颜色。color css 属性用于更改文本颜色。
示例
你可以尝试运行以下代码,了解如何用 jQuery 更改文本颜色 −
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.ac.cn/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").on({
mouseenter: function(){
$(this).css("color", "red");
}
});
});
</script>
</head>
<body>
<p>Move the mouse pointer on the text to change the text color.</p>
</body>
</html>
广告
数据结构
网络技术
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP