我們的一個老開發商已經建立了一個jQuery插件,像這樣:的jQuery插件暴露功能
jQuery.fn.limelight = function(options) {
/*Skipped code here*/
jQuery(".spotlight-btn.back a").click(function (e) {
if(lastSelectedCastIndex - 1 >= 0) {
removeFromSpotlight();
lastSelectedCastIndex--;
e.preventDefault();
$.address.value(lastSelectedCastIndex);
ca$t.scroll(jQuery.jcarousel.intval(lastSelectedCastIndex), true);
switchTo(lastSelectedCastIndex);
}
return false;
});
function switchTo(i)
{
ca$t.scroll(jQuery.jcarousel.intval(i), true);
$.address.title($("#title_text").text());
putInSpotlight();
}
};
我沒有做任何的jQuery插件程序,但想暴露switchTo
功能,因此它可以被稱爲任何地方。我將如何能夠做到這一點?
多麼簡單....只是把它移到全球範圍。 – vsync