admin 管理员组文章数量: 1086019
Now I have googling this a lot, but I cant seem to find what I am looking for. I am not talking about the options object that does drop down menus, I am talking about seeing stuff like
options.remove, options.enable, options.instance,
To be honest, I am not sure if the code I am trying to figure out already created some object called "options" or if its a pre-built javascript object. It lights up purple in my dreamweaver editor so I have a feeling its a pre-built object. I am new, sorry.
Now I have googling this a lot, but I cant seem to find what I am looking for. I am not talking about the options object that does drop down menus, I am talking about seeing stuff like
options.remove, options.enable, options.instance,
To be honest, I am not sure if the code I am trying to figure out already created some object called "options" or if its a pre-built javascript object. It lights up purple in my dreamweaver editor so I have a feeling its a pre-built object. I am new, sorry.
Share Improve this question asked Jun 22, 2010 at 1:11 anthonypliuanthonypliu 12.4k28 gold badges95 silver badges154 bronze badges4 Answers
Reset to default 31An options object is an object passed into a method (usually a method that builds a jQuery widget, or similar) which provides configuration info.
An options object is usually declared using object literal notation:
var options = {
width: '325px',
height: '100px'
};
The options that are valid depend on the method or widget that you are calling. There is nothing 'special' about an options object that makes it different from any other javascript object. The object literal syntax above gives the same result as:
var options = new Object();
options.width = '325px';
options.height = '100px';
Example:
$( ".selector" ).datepicker({ disabled: true });
//create a jQuery datepicker widget on the HTML elements matched by ".selector",
//using the option: disabled=true
There is no standard, universal object called options
.
Most likely what's meant is that the library you're using happens to have a variable named options
that has properties like remove
, enable
, and instance
.
It's fairly common for library functions to take an options
argument specifying... well... options — that is, supplementary settings the function can exploit. In cases where there are many variables you may want to set, a single object with those properties is cleaner than a function that takes a hundred ordered arguments.
It is probably just a variable that the script created to hold a bunch of values.
var myoptions = new Object();
myoptions.done = 1;
myoptions.welcome = 'Hello Dave'
myoptions.error = "I'm sorry dave, I can't do that".
I would guess that the options object is just JSON. It is created from
{ "options": { "remove": true, "enable": false, "instance": object }
That is how most Javascript libraries load/set options. You can reference the objects properties just like you are doing in the question.
本文标签: jqueryIn JavaScript what is an options objectStack Overflow
版权声明:本文标题:jquery - In Javascript, what is an options object? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1737546228a1841975.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论