Solved

remove html select option using jquery

Posted on 2010-09-15
2
248 Views
Last Modified: 2012-05-10
Hello,

I'm trying to dynamically remove an html select option item but I'm unable to get it to remove unless I hardcode the option value. I need to remove the select option based on the value passed to the function below...any ideas on where I've gone wrong?
function loadGallery(albumId, albumTitle){
	$("#selectAlbum option[value='37']").remove(); //hard coding it works
        $("#selectAlbum option[value=' + albumId + ']").remove(); //this doesn't work, but no error

}

Open in new window

0
Comment
Question by:cgray1223
[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
2 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 33688852
make it
$("#selectAlbum option[value='" + albumId + "']").remove();
0
 
LVL 14

Expert Comment

by:sam2912
ID: 33688882
I believe you do not need the single quotes
$("#selectAlbum option[value=" + albumId + "]").remove();

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTML INPUT 6 36
Table header must be on top 2 54
sort Multi-dimensional array 6 41
How does GeoJson relates to Leaflet and Mapbox? 4 43
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

739 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