views:

118

answers:

1

Hello all, I'm trying to create an <ol> element with jQuery and set its class and id attributes. Is there any way to do this all at once? None of my ideas have worked so far, I'm still very new to jQuery...

+3  A: 

There are at least a couple of different ways to do this:

$('<input id="something" class="something-else" type="text" />')
      .appendTo('#someSelector');

or

$('<input type="text" />').attr('id','something')
                          .addClass('something-else')
                          .appendTo('#someSelector');
tvanfosson
Thanks man, worked perfect!
danwoods