erikTsomik
asked on
remove li with a spesific id in Jquery
I needto remove li with a specific id but it does not work..
Here is what I using
$("li[@id=" + $(this).val() + ']').remove();
Here is what I using
$("li[@id=" + $(this).val() + ']').remove();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the ID selector is : #
ASKER
My html code is this . How would I remove all elements not just li but ul an label
<label></label>
<ul class="options">
<li id="1">John</li>
</ul>
<label></label>
<ul class="options">
<li id="1">John</li>
</ul>
Why a new question?
ASKER
it just a part of it
erikTsomik thanks for your answer.
I suppose you want to remove label and ul around the given LI
<label></label>
<ul class="options">
<li id="1">John</li>
</ul>
I think you shoud use a container for all :
<div class=".containerClass">
<label></label>
<ul class="options">
<li id="1">John</li>
</ul>
</div>
and now you can use :
$("#" + $(this).val()).closest(".c ontainerCl ass").remo ve(); // or if you really prefer your syntax (not recommended) : $("li[id=" + $(this).val() + ']').closest(".containerCl ass").remo ve();
I suppose you want to remove label and ul around the given LI
<label></label>
<ul class="options">
<li id="1">John</li>
</ul>
I think you shoud use a container for all :
<div class=".containerClass">
<label></label>
<ul class="options">
<li id="1">John</li>
</ul>
</div>
and now you can use :
$("#" + $(this).val()).closest(".c
ASKER
$("li[id=" + $(this).val() + ']').remove();