How to set margin with jquery?

前端 未结 2 959
北海茫月
北海茫月 2021-02-05 00:53

I am doing this:

var sId=id.toString();
var index=sId.substring(3);
var mrg=index*221;
var el=$(id);
el.css(\'margin-left\',mrg+\'px\'); and el.css(\'marginLeft\         


        
相关标签:
2条回答
  • 2021-02-05 00:55

    Set it with a px value. Changing the code like below should work

    el.css('marginLeft', mrg + 'px');
    
    0 讨论(0)
  • 2021-02-05 01:20

    try

    el.css('margin-left',mrg+'px');
    
    0 讨论(0)
提交回复
热议问题