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.
// Explicit global $.fn.getRedemptionID = function(){ window.varMy = data.DATA[0].item1; }
如何调用上述函数来获取变量 varMy ?
从你之前的问题来看,我认为你基本上希望将 var 返回到调用部分..然后你可以写如下,
$.fn.getRedemptionID = function(){ return data.DATA[0].item1; }
并打电话,
var myVar = $(selector).getRedemptionID();
附加的函数$.fn是 jQuery 插件。它们需要在 jQuery 对象上调用。
$.fn
例如:
$('#myDiv').getRedemptionID();