【发布时间】:2020-11-07 20:16:34
【问题描述】:
我有一个类为 .ban2 和 id 为 #banner2 的 div。
每当我单击 div 本身时,我都想更改该 div 的border-radius 属性。就像我第一次单击它时,边框半径变为 0,当我再次单击时,它又回到 50% 0 0 50%。
我想在这两种风格之间切换。在我的 .ban2Toggle 类中,我包含了所有样式,但边框半径为 0。
它只工作一次,就像我第一次单击它时边框半径变为 0。下次我单击它时,我不知道如何使其恢复正常。
.banner .ban2{
position: absolute;
right: 0;
top: 0;
width: 40%;
height: 63vh;
background: #5a0980;
border-radius: 50% 0 0 50%;
transform: scaleY(1.6);
display: flex;
justify-content: center;
align-items: center;
transition: 1s ease;
}
$('#banner2').on('click', function(){
$('#banner2').removeClass('ban2');
$('#banner2').addClass('ban2Toggle');
});
【问题讨论】:
标签: javascript html jquery css toggle