如何在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 送女士祝福语长辈简短
12 喜得新房文案祝福语简短
13 发廊元旦祝福语大全简短
14 家长祝福语大全简短内容
15 儿媳买车妈妈祝福语简短
16 周末祝福语正能量简短
17 送个姐妹生日祝福语简短
18 祖国七十华诞简短祝福语