Library - JQuery

Back to Course

Lesson Description

Lession - #568 JQuery Add

The add(>
method adds elements to associate existing group of elements. This method adds components on the complete document, or just inside context components if the context parameter is specified.

Jquery add methods
  • append(>
    - Inserts content at the end of the selected components
  • prepend(>
    - Inserts content at the start of the selected components
  • after(>
    - Inserts content after the selected components
  • before(>
    - Inserts content before the selected components

     <title> jQuery Example</title>  
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">  
    { $("#btn1">
    { $("p">
    .append(" Appended text.">
    ; }>
    ; $("#btn2">
    { $("ol">
  • Appended item
  • ">
    ; }>
    ; }>
    ; </script> </head> <body> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <ol> <li>List item 1</li> <li>List item 2</li> <li>List item 3</li> </ol> <button id="btn1">Append text</button> <button id="btn2">Append list items</button> </body> </html>
    Try it here