?
Solved

remove html select option using jquery

Posted on 2010-09-15
2
Medium Priority
?
250 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:
Gurvinder Pal Singh earned 2000 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

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
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