如何调用jQuery包装器$(function(){}的内部函数? [英] How to call inner function of jQuery-wrapper $(function() { }?
本文介绍了如何调用jQuery包装器$(function(){}的内部函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在jQuery包装器中有一个changeGraph()函数,我需要从外部调用它.我需要从基于jQuery的图形库Flot中访问函数setData.
I've got a function changeGraph() inside the jQuery-wrapper which I need to call somehow from outside it. I need to access the function setData from the jQuery based graph-library Flot.
来源看起来像这样:
function changeGraph(){
// I need to access $.plot.setData somehow
};
var d2 = [[0, 0], [20, 300000]];
$(function () {
$.plot($("#placeholder"),
[{color: "#000000", data: d2}],
{
series: {
lines: { show: true, fill:true, fillColor: {colors: [ "#d1ddea","#8e959d"]}},
points: { show: false }
}
}
);
});
我该怎么做?
推荐答案
var changeGraph;
$(function () {
changeGraph = function () {
// Need to access $.plot($("#placeholder") here
};
});
changeGraph(); // call this when document is ready at least
这篇关于如何调用jQuery包装器$(function(){}的内部函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文