You will use jQuery or javascript for this, and can also be done only with CSS.
I’ll give you an answer with jQuery, just add an event 'click'
to remove button, and remove the nearest li element searched with 'closest'
, in this case I used the method hide()
, but there are also other methods.
Following functional example:
$(document).on('click','.remover',function(){
$(this).closest('li').hide();
});
$(document).on('click','.mostrar',function(){
$(this).closest('ul').find('li').show();
});
.remover {
text-decoration: none;
float:right;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
<li>
coisa 1 <a href="#" class="remover fa fa-minus"> </a>
</li>
<li>
coisa 2 <a href="#" class="remover fa fa-minus"> </a>
</li>
<li>
coisa 3 <a href="#" class="remover fa fa-minus"> </a>
</li>
<li>
coisa 4 <a href="#" class="remover fa fa-minus"> </a>
</li>
<li>
<a href="#" class="mostrar"> (Mostrar tudo)</a>
</li>
</ul>
PS: There are several answers that would answer this question, in my opinion jQuery makes life easier.
What is the HTML/Javascript of this list?
– Sergio
I’ll edit with the code for a moment
– Sora
I put a basic code from a list
– Sora