在Javascript中,选项对象是什么? [英] In Javascript, what is an options object?

查看:114
本文介绍了在Javascript中,选项对象是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我已经在谷歌上搜索了很多东西,但是我似乎找不到我想要的东西.我不是在谈论确实会下拉菜单的options对象,我是在谈论看到

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, 

说实话,我不确定我要弄清楚的代码是否已经创建了一个称为"options"的对象,或者它是否是一个预先构建的javascript对象.在我的Dreamweaver编辑器中它会亮起紫色,因此我感觉到它是一个预先构建的对象.我是新来的,对不起.

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.

推荐答案

options对象是传递给提供配置信息的方法(通常是构建jQuery小部件或类似方法的方法)的对象.

An 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'
};

有效的选项取决于您所调用的方法或窗口小部件.选项对象没有什么特殊"之处,使其与任何其他javascript对象都不同.上面的对象文字语法给出与以下结果相同的结果:

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';

示例:

$( ".selector" ).datepicker({ disabled: true });
//create a jQuery datepicker widget on the HTML elements matched by ".selector",
//using the option: disabled=true

这篇关于在Javascript中,选项对象是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆