开发者

Extended function jquery

开发者 https://www.devze.com 2022-12-14 02:50 出处:网络
I have a functi开发者_运维知识库on that looks like this: jQuery.fn.menuFunc = function( settings ) {

I have a functi开发者_运维知识库on that looks like this:

jQuery.fn.menuFunc = function( settings ) {
        settings = jQuery.extend({ 
          actionAddURL:"",
          actionModifyURL:"",
          ........
          },settings);};

where all the parameters i initialize (actionAddURL, actionModifyURL, etc..) are strings (ids of different elements or urls). My question is how do i add some objects there. myObject:"" doesn't seem to be the way to do it. Any tips?


myObject:[] // empty JavaScript object
,
myOtherObject: { // JavaScript object notation
       name: "Bob",
       age: 17
      }


Probably:

myObject: {}

is what you are looking for.

You can then add properties to it:

myObject.name = "Name";


To define an object you could use the following syntax:

myObject: { stringProp: 'value1', intProp: 10, arrayProp: [ 1, 2, 3 ] }
0

精彩评论

暂无评论...
验证码 换一张
取 消