jquery exercises

jQuery: Click on a paragraph and add another paragraph

jQuery Fundamental - II : Exercise-75

Click on a paragraph and add another paragraph.

Sample solution :

HTML Code :

<!DOCTYPE html>
<script src="https://code.jquery.com/jquery-git.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Click on a paragraph and add another paragraph.</title>
<p>Click me to add new paragraph.</p>

CSS Code :

 p {
 background: orange;
 font-weight: bold;
 cursor: pointer;
 padding: 5px;

JavaScript Code :

$( "body" ).delegate( "p", "click", function() {
$( this ).after( "<p>New paragraph!</p>" );

See the Pen jquery-fundamental-exercise-75 by w3resource (@w3resource) on CodePen.

Contribute your code and comments through Disqus.

Previous: Animate the hiding and showing of two divs, delaying the first before showing it.
Next: End a custom queue function using dequeue which allows the queue to keep going.

What is the difficulty level of this exercise?

New Content: Composer: Dependency manager for PHP, R Programming