0
Follows illustration for clarification
I’m stuck on a logic and my problem is this, I have this html code:
<ul class="card"></ul>
<button>
Aperteme
</button>
and do an action with this Jquery:
$('button').on('click',function(){
$('.card').append(`<li> Teste </li>`)
})
The logic is this: I have a button, whenever I click on it
he makes an append in mine .card
, but what I would like if my .card
if you already have an element, instead of creating a new row, it just groups with the existing one.
Type that occurs when I use the command .html
but with . html it is sub-created and there is only one element and does not return all.
The moment whenever I click it generates a new append, I want q if there is already an append done before, it just groups the append.
It wouldn’t just change the append() to appendTo()?
$( "<li> teste </li>").appendTo( ".card" )
– Victor Laio
What do you mean "group"? You want to put a
li
inside of anotherli
?– Sam