Posted By

batamire on 02/07/11


Tagged

node DOM jquery create


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

vitor_np
albertomori
scottwatkins


Element creation with jQuery


 / Published in: jQuery
 

URL: http://thenerdary.net/articles/entry/beautiful_element_creation_with_jquery#When:16:29:12Z

  1. var anchor = $('<a />', {
  2. className: 'awesome',
  3. href: '#',
  4. text: "This is an anchor ",
  5. click: function(e){
  6. e.preventDefault();
  7. $(this).parent().slideToggle();
  8. }
  9. });
  10.  
  11. $("li").each(function(){
  12. $(this).prepend(anchor.clone());
  13. });

Report this snippet  

You need to login to post a comment.