jQuery help us to create an HTML elements and insert them into a page.
If we pass a text string that spells out a new HTML element to the jquery ( ) or $( ) function (which are the same thing), jQuery will create that new element:
$(“<p>I’m a new <p>element!</p>”)
The upper code will display ” I’m a new <p> element ! “
To actually get the new element into a page, we have to use a function like insert After () , passing a selector indicating the element that you want to insert the new element after.
This tutorial creates new <p> elements and inserts them into a page following a <p> element with the ID “first”, like this:
$(“
I’m a new <p>element!
”).insertAfter(“#first”);
To create new elements:
1. We are going to use text editor (such as notepad or Wordpad) to create our HTML page and give the file name as “create.html”.
2. Enter the code to add the jQuery libraryand add a element with the ID “first”. Read the rest of this entry »