How do I put a variable in a string using javascript

前端 未结 4 583
慢半拍i
慢半拍i 2021-01-26 05:51

How do I put a variable in a string in JavaScript?

Example:

$(\'#contactForm\').animate({\"marginLeft\": \"+=680px\"}, \"slow\");

I wou

4条回答
  •  迷失自我
    2021-01-26 06:00

    var theWidth = "680px"
    $('#contactForm').animate({marginLeft: "+=" + theWidth}, "slow");
    

提交回复
热议问题