我有以下 jquery 代码。
if(bubble.label != undefined){
console.log(bubble.label.attr('style'));
var bubbleStyle = bubble.label;
bubbleStyle.css({
color: 'red',
left: 0+'px',
top: -660+'px'
});
}
在上面的代码中,css 属性 color: 'red' 适用,但不适用 left 和 top 。我已经尝试过给出 position : 'absolute' 但它仍然不起作用。请帮我解决这个问题。谢谢。
最佳答案
尝试使用:
left: 0,
top: -660
代替:
left: 0+'px',
top: -660+'px'
关于jquery css 属性顶部和左侧不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23422432/