开发者

Extended function jquery

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜