How can a div be declared to use as a template (without a function)?

 div = $('<div class="not"></div>'); a = div.addClass('x'); b = div.addClass('y'); c = div.addClass('z'); alert(div.attr('Class')); // <-- Чтобы у div остался только класс "not" 
  • one
    No You either change this div by calling .addClass (), or not. - etki
  • maybe div.clone () will do? - zhenyab
  • @Etki, Again, not as an answer? :) - user31688
  • @zhenyab, clone () that works, but I wanted not to write too much. We had to do through the function function div() {return $('<div></div>');} div().addClass('x'); I don’t know right now, profes will cast aside shit and give me the status of google coder! [Alt text] [1] [1]: vk.com/images/emoji_2x/D83DDCA9.png - user27286
  • 2
    @Doofy, in jQuery html, it is customary to create like this: $ ('<div>', {'class': 'superclass', 'data-item-id': someId}); your function is easily replaced by $ ('<div>'). addClass ('x'); - etki

0