Posted By

batamire on 02/07/11

Tagged

DOM jquery

Viewed 1 times

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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.