如何在jQuery中的两个类之间切换?
要在jQuery中的两个类之间切换,请使用addClass()和removeClass()方法。您可以尝试运行以下代码在jQuery中的两个类之间切换-
示例
<html>
<head>
<script src = "https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("a").click(function(){
$("a.active").removeClass("active");
$(this).addClass("active");
});
});
</script>
<style>
.active {
font-size: 22px;
}
</style>
</head>
<body>
<a href="#" class="one">One</a>
<a href="#" class="two">Two</a>
<p>Click any of the link above and you can see the changes.</p>
</body>
</html>热门推荐
10 生日祝福语古语简短创意
11 14年祝福语简短情话
12 老婆生日祝福语简短孩子
13 姨父生日祝福语简短精辟
14 离别祝福语简短送同事
15 新老师祝福语 简短独特
16 2026年祝福语大全简短
17 前程祝福语简短暖心
18 新年元旦祝福语大全简短