如何使用jQuery更改CSS?
要使用jQuery更改CSS,请使用jQuerycss()方法。
示例
您可以尝试运行以下代码来使用jQuery更改CSS:
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("h2").css("backgroundColor", "red");
    $("#myid").css({
        "backgroundColor": "gray",
        "color": "white"});
    $(".myclass").css("border", "2px solid black");
});
</script>
</head>
<body>
<h2>Heading 2</h2>
<p id="myid">This is some text.</p>
<div class="myclass">This is some text.</div>
</body>
</html>