如何用 jQuery 更改文字顏色?
使用 jQuery css() 方法更改文字顏色。color css 屬性用於更改文字顏色。
示例
你可以嘗試執行以下程式碼,瞭解如何用 jQuery 更改文字顏色 −
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/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