我像这样激活一个 jQuery 脚本:
$('#an-id').drawbox();
这是 jQuery 脚本(重要部分):
(function($)
{
$.fn.extend(
{
drawbox: function()
{
// Default options
var defaults = {
caption: 'Caption',
// Canvas properties
lineWidth: 3,
lineCap: 'round',
lineJoin: 'round',
miterLimit: 10,
strokeStyle: 'green',
fillStyle: 'none',
shadowOffsetX: 0.0,
shadowOffsetY: 0.0,
shadowBlur: 0.0,
shadowColor: 'none',
}
options = $.extend(defaults);
return this.each(function()
{
//etc
该脚本运行良好,但我想稍后在单独的脚本中获取“选项”值。我猜选项设置已设置并存储在函数中,以后可以检索。
我试过这样的事情:
$('#an-id').drawbox.options
...但似乎无法得到它。