gpt4 book ai didi

function - jQuery 中点击后删除 CSS

转载 作者:行者123 更新时间:2023-12-01 01:16:00 35 4
gpt4 key购买 nike

我有这样的结构:

$('.user_adr_edit div a').click(function(){
$(this).css('width', '210px');
});

它正在工作。但我想,当再次单击时,删除 width:210px

必须使用unbind , remove或者其他解决方案?

最佳答案

您应该使用 css 规则来更改 css 属性

CSS

a.wide{
width:210px;
}

只需添加/删除类

$('.user_adr_edit div a').click(function(){
$(this).toggleClass('wide');
});

关于function - jQuery 中点击后删除 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15364100/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com