這裏的值是摘自我的大JavaScript文件:我想JavaScript通過可變公共
function dashboardConfig()
{
$(window).on('resize', function() {
var viewport = {
width : $(this).width(),
height : $(this).height()
};
el.siteContainer.css(
{
marginTop : (viewport.height - 652)/2
});
el.dashboardSlide.css(
{
marginLeft : (viewport.width - 1024)/2,
marginRight : (viewport.width - 1024)/2
});
//Calculate how many nav elements
el.navElements.each(function(i)
{
el.dashboard.css(
{
width : viewport.width * (i + 1)
});
$(this).click(function()
{
//HERE IS THE VARIABLE I WOULD LIKE TO USE
var dashboardSlidePosition = viewport.width * i;
el.navElements.removeClass('active');
$(this).addClass('active');
el.dashboard.animate(
{
left : -dashboardSlidePosition
},500, function()
{
el.dashboard.css(
{
left : -dashboardSlidePosition
});
});
});
});
//I WANT TO PERFORM ANOTHER FUNCTION HERE AND HAVE IT USE THE VALUE OF dashboardSlidePosition
}).trigger('resize');
}
知道我怎麼能傳遞變量,dashboardSlidePosition的價值,另一種功能。請任何人都可以解釋一下?
非常感謝提前。
在更高的範圍內聲明它。 – elclanrs