Jquery 动态添加CSS
我尝试了以下JQuery方法来动态替换CSS值,但它不起作用。知道哪一部分错了吗 在我的html中:Jquery 动态添加CSS,jquery,css,Jquery,Css,我尝试了以下JQuery方法来动态替换CSS值,但它不起作用。知道哪一部分错了吗 在我的html中: <div class="svg"> <button class="type_1"></button> </div> 我当前的方法不起作用: $('.svg .type_' + list.id).css({ stroke: list.hex_color, fill: list.hex_color });
<div class="svg">
<button class="type_1"></button>
</div>
我当前的方法不起作用:
$('.svg .type_' + list.id).css({
stroke: list.hex_color,
fill: list.hex_color
});
如果存在连接问题,则必须将css用引号括起来
$('.svg .type_' + list.id).css({
'stroke': list.hex_color,
'fill': list.hex_color
});
svg svg?尽管您的div具有svg类,但不应应用CSS,因为它是针对svg的element@phuzi我只想用动态添加的css替换当前固定的css svg.type_1{rgb…},只需删除点:$'.svg.type_'+list.id→ ` $'svg.type_'+list.id`。我尝试了这个方法,它不起作用,我如何检查这个动态添加的CSS是否在那个网页上提供?我想看看它是否覆盖了最初的CSS
$('.svg .type_' + list.id).css({
'stroke': list.hex_color,
'fill': list.hex_color
});