0
如何让变量“theOffset”在“localScroll”函数内工作。这是我的非工作代码:帮我使用javascript变量的范围
jQuery(function($){
//initialize variable "theOffset"
theOffset = 10; // <-- sets variable for inside of "localScroll" function
$(window).resize(function() {
theOffset = 20; // <-- does NOT reset inside "localScroll" function
}); // end of window resize
$.localScroll({
target: '#content',
duration:1500,
hash:true,
offset: {top:0, left: theOffset}, // <-- I want to reset this on window resize
onBefore:function(e, anchor, $target){
},
onAfter:function(anchor, settings){
}
});
});
应该把'之前的任何变量,你不希望在全球范围内var'。 – mpen 2010-11-18 22:38:22
你可以编辑你现有的问题http://stackoverflow.com/questions/4219478/javascript-variable-not-working-why与新的细节,不需要在同一问题上开始新的问题。 – 2010-11-18 22:40:46
aaahh。我仍然在学习stackoverflow的方法。 – Dave 2010-11-18 22:45:39