Solved

remove li with a spesific id in Jquery

Posted on 2011-09-07
7
626 Views
Last Modified: 2012-05-12
I needto remove li with a specific id but it does not work..

Here is what I using
$("li[@id=" + $(this).val() + ']').remove();
0
Comment
Question by:erikTsomik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36496867
$("li#" + $(this).val()).remove();

should work (a unique ID per element) :
$("#" + $(this).val()).remove();

0
 
LVL 19

Author Comment

by:erikTsomik
ID: 36496874
I use this and it works
$("li[id=" + $(this).val() + ']').remove();
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36496882
the ID selector is : #

0
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
LVL 19

Author Comment

by:erikTsomik
ID: 36496896
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>
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36496913
Why a new question?
0
 
LVL 19

Author Comment

by:erikTsomik
ID: 36496923
it just a part of it
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36497103
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(".containerClass").remove(); // or if you really prefer your syntax (not recommended) : $("li[id=" + $(this).val() + ']').closest(".containerClass").remove();

0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question