I have some code at here:
html:
<body>
<p>This is a paragraph.</p>
<button>click me</button>
</body>
Javascript:
$(document).ready(function(){
$("button").click(function(){
$("p").hide().after('<p>hello world</p>');
});
});
Actually, I've using JQuery 2.0.2
also.
In my understanding, When I click the button click me,
"<p>This is paragraph<p>"
will be replaced by <p>hello world</p>
.
The first click is successful. However, many hello world
with the growth rate of progression show after the first hello world
shown. For example:
I've checked the source code by firebug, and find it is:
<p style="display: none;">This is a paragraph.</p>
<p>hello world</p>
<p style="display: none;">hello world</p>
<p>hello world</p>
<button>click me</button>
Why the first <p>hello world</p>
wasn't be replaced by the new one?
Doesn't it suppose to show one p tag only?
hello world
');` see http://jsfiddle.net/arunpjohny/M6QTc/2/ – Arun P Johny Dec 25 '13 at 07:10