{"id":749,"date":"2012-06-04T22:16:14","date_gmt":"2012-06-04T22:16:14","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=749"},"modified":"2012-06-04T22:16:14","modified_gmt":"2012-06-04T22:16:14","slug":"jquery-create-div-4-ways-to-create-div-element-using-jquery","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/jquery-create-div-4-ways-to-create-div-element-using-jquery\/","title":{"rendered":"jQuery Create DIV Examples (4 Easy Ways)"},"content":{"rendered":"<p>Did you always wonder how to use jQuery to create div? \u00a0In this article, I am going to show you <em><strong>4 ways of creating div using jQuery<\/strong><\/em>.<!--more--><\/p>\n<h2>Examples of using jQuery to Create DIV<\/h2>\n<p>Let&#8217;s assume that you have a div with ID &#8220;destination&#8221;. Let&#8217;s see how you can create a div element in this &#8220;destination&#8221; div:<\/p>\n<h3>Example 1: By using .html() method in jQuery:<\/h3>\n<pre class=\"lang:js decode:true\">\/\/Use: html() - Overwrites any existing content of #destination and replaces it with custom text\n$(\"#destination\").html(\"&lt;div&gt;This is some custom text&lt;\/div&gt;\");<\/pre>\n<h3>Example 2 &#8211; By using .append() method in jQuery:<\/h3>\n<pre class=\"lang:js decode:true\">\/\/Use: append() - Adds the custom text at the end of the existing text in #destination\n$(\"#destination\").append(\"&lt;div&gt;This is some custom text&lt;\/div&gt;\");<\/pre>\n<h3>Example 3 &#8211; By using .appendTo() method in jQuery:<\/h3>\n<pre class=\"lang:js decode:true\">\/\/Use: appendTo() - Adds the custom text at the end of the existing text in #destination\n$(\"&lt;div&gt;This is some custom text&lt;\/div&gt;\").appendTo(\"#destination\");<\/pre>\n<h3>Example 4 &#8211; By using .prependTo() method in jQuery:<\/h3>\n<pre class=\"lang:js decode:true\">\/\/Use: prependTo() - Adds the custom text at the beginning of the existing text in #destination\n$(\"&lt;div&gt;This is some custom text&lt;\/div&gt;\").prependTo(\"#destination\");<\/pre>\n<h5>Very easy, isn&#8217;t it?<\/h5>\n<p>Do you know of any other ways to <em><strong>create div using jQuery<\/strong><\/em>? Feel free to share by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Did you always wonder how to use jQuery to create div? \u00a0In this article, I am going to show you 4 ways of creating div using jQuery.<\/p>\n","protected":false},"author":1,"featured_media":395,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[20,13],"tags":[41],"class_list":["post-749","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery-tips-and-tricks","category-tips-and-tricks","tag-jquery-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-c5","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/749","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=749"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/749\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}