Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要使用“wbanner”来移动一个 div,但是 marginLeft 不将变量识别为一个值
$(document).ready(function() { var wbanner = (screen.width/2)-175; $('.banner').hide().show(1000).animate({marginLeft : "+=$('.wbanner')"}, 3000).css('color', '#85bbd7'); )}
您无需选择变量,只需像这样使用它:
function() { var wbanner = (screen.width/2)-175; $('.banner').hide().show(1000).animate({marginLeft : "+=" + wbanner}, 3000).css('color', '#85bbd7');