Element creation with jQuery


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  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. });

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.