I have this line of code:
var bgposh = "-37";
$(element).find('.toggle_box').css({'-webkit-transition': 'background-position 0.2s linear', 'background-position': '147px "+ bgposh +"px'});
but the background position does not get set. I think it is because there is no space between px 开发者_运维问答and bgposh. How can I add one? I tried + + but that does not seem to work.
Thanks a lot :)
Little syntax error i think with your bgposh variable
$(element).find('.toggle_box').css(
{'-webkit-transition': 'background-position 0.2s linear',
'background-position': '147px '+ bgposh +'px'
});
No, it is because with this code you have set background-position
to 147px "+ bgposh +"px
.
You have wrong quotes. The correct version looks like this (notice different quotes):
$(element).find('.toggle_box').css({
'-webkit-transition': 'background-position 0.2s linear',
'background-position': '147px ' + bgposh + 'px'
});
精彩评论