Does the addition only work for the first item found?

advertisements

Does append work only for the first found element?

<div id='parent'> <strong> </strong> </div>
<div id='parent'> <strong> </strong> </div> 

$('#parent').append('Text inside div');

I could see Text inside div printed only once when I run the html.

PS : This works :

$('#parent>strong').append('Text inside div');

It prints the text twice.


Use classes instead of id, because ID must be unique

$('.parent').append('Text inside div');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='parent'> <strong> </strong> </div>
<div class='parent'> <strong> </strong> </div>