corry
corry

Reputation: 1529

Multiple HTML div elements in single javascript object property

Is it possible to use mulitple HTML div elements inside one JS object property (content in the example below):

$.Box({
                title : "Title",
                content : "<table id='1'></table>",
                "<table id='2'></table>"

            });

Upvotes: 0

Views: 24

Answers (2)

KpTheConstructor
KpTheConstructor

Reputation: 3291

You would have to store them in an array .

Example 1 :

$.Box({
     title : "Title",
     content : ["<table id='1'></table>","<table id='2'></table>"]
  });

Example 2 :

 $.Box({
     title : "Title",
     content : function(){
        var format = ["<table id='1'></table>","<table id='2'></table>"];
        //do something to the format
       return format.join(" ");
      }()
  });

Hope this helps

Upvotes: 1

charlietfl
charlietfl

Reputation: 171669

That isn't valid javascript for an object

Put all the html inside same quotes so it is all one string

$.Box({
       title : "Title",
       content : "<table id='1'></table><table id='2'></table>"
});

Or use a + to concatenate the string parts

$.Box({
       title : "Title",
       content : "<table id='1'></table>" + 
                 "<table id='2'></table>"
});

Upvotes: 1

Related Questions