Create new element with JQuery

linkaiyi
Follow

create new element

$( "<div/>", {
  "class": "test",
  text: "Click me!",
  click: function() {
    $( this ).toggleClass( "test" );
  }
})
  .appendTo( "body" );
this.$OuterDiv = $('<div></div>')
    .hide()
    .append($('<table></table>')
        .attr({ cellSpacing : 0 })
        .addClass("text")
    )
;

Or createElement can be used as well. eg.

$("<div>") vs $("<div></div>") vs $(document.createElement('div'))
Object has 0 attachments

Was this article helpful?

This article is viewed 60 times!

Recent Viewed Articles

0 Comments

Leave a Comment

Support