New to jQuery, I wish to know how to add many <p>
tags under one <div>
tag. Actually, I have this code :
<body>
<div id="clickMe"> Click here to change text </div>
<div id="addFrame">
<p> You didn't click yet. </p>
</div>
<script>
$("document").ready(function(){
$("#clickMe").click(function(){
$("#addFrame").add("p").text("Oh, you clicked !");
});
})
</script>
</body>
I want to click on the clickMe
div and add many <p>
tags under my addFrame
div, thus, This HTML :
<div id="addFrame">
<p> You didn't click yet. </p>
</div>
Will become after clicking something like this :
<div id="addFrame">
<p> Oh, you clicked ! </p>
<p> Oh, you clicked ! </p>
</div>
In order to achieve that, I tried this :
$("document").ready(function(){
$("#clickMe").click(function(){
$("#addFrame").add("p").text("Oh, you clicked !");
$("#addFrame").add("p").text("Oh, you clicked !");
});
})
But only one p
is added.
Is there some function (tried appendTo() as well, adds just one) I am not aware of that's able to accomplish this ?