?
Solved

remove li with a spesific id in Jquery

Posted on 2011-09-07
7
Medium Priority
?
631 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 2000 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
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

762 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