jquery add html code example

Example 1: jquery create html element

var newDiv = $('<div>My new div</div>');  //create Div Element w/ jquery
$( "#someOtherElement" ).append(newDiv); //append new div somewhere

Example 2: jquery add div element

$('#someParent').append('<div>I am new here</div>');

Example 3: how to add jquery to html

<!--You can insert Jquery into HTML with the <script> tag.-->
<head>
  <script type = 'text/javascript' src = 'https://code.jquery.com/jquery-3.3.1.js'></script>
</head>

Example 4: jquery append

$("p").append(" <b>Appended text</b>.");

Example 5: append after element jquery

$("p").after(" <b>You can write your Text Here </b>.");

Example 6: create an element jquery

$('<div>hello</div>').appendTo('#parent');

Tags:

Html Example