jQuery: Create a paragraph element with some text and append it to the end of the document
jQuery Fundamental - I : Exercise-3
Create a paragraph element with some text and append it to the end of the document body using jQuery.
Sample solution :
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-git.js"></script> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Create a paragraph element with some text and append it to the end of the document body using jQuery.</title> </head> <body> <p>jQuery</p> </body> </html>
$( "p" ).add( "<span>Exercises</span>" ).appendTo( document.body );
Used Methods :
- .add(elements) : Create a new jQuery object with elements added to the set of matched elements.
- .appendTo() : Insert content, specified by the parameter, to the end of each element in the set of matched elements.
Contribute your code and comments through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook