jQuery create a new element


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



Copy this code and paste it in your HTML
  1. $('<div>',{
  2. id: 'test',
  3. text: 'This is the element text',
  4. class: 'Paul',
  5. click: function(){
  6. alert('Liverpool');
  7. }
  8. }).insertAfter('article');

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.