要使用jQuery更改文本颜色,请使用jQuerycss()方法。color css属性用于更改文本颜色。
您可以尝试运行以下代码以了解如何使用jQuery更改文本颜色-
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.staticfile.org/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>