hello ,
i expect from the below code to add paragraph to each li element and then add "hi" to each paragraph inside the li element , but the code will also change the original paragraphs content to "hi" and it will works as i expect if i add index with any number to p element like this $('li').add('p[0]').html('hi');
<html>
<body>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(e) {
$('li').add('p').html('hi');
});
</script>
<ul>
<li ></li>
<li></li>
<li ></li>
</ul>
<p>First paragraph</p>
<p>second paragraph</p>
</body>
</html>