In Javascript, what is an options object?

后端 未结 4 1234
忘掉有多难
忘掉有多难 2021-02-12 13:33

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 st

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-12 13:50

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

    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
    

提交回复
热议问题