Tuesday, 15 May 2012

javascript - jQuery .add() using generated element not working -


I am trying to loop through an array, so that its values ​​can be used to create the collection of elements. Which can later be added to the DOM.

By doing this, I am using this code:

  $ (). Add ($ ('& lt; span / & gt;', {class: 'child', text: 'test'})). Attachments ('Container');   

Or something like this ... the generated element is not added to the collection here with a simple example:

Just use a simple array and push your elements into your array. var spans = new array (); Console.log (spans.length); Spans.push ($ ('& lt; span / & gt;', {class: 'child', text: 'test'})); Console.log (spans.length); $ ('. Container') attached (spread).

In your post-bedel you are mixing container and parent class, which is why app () still does not work. Have given.

No comments:

Post a Comment