• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

remove html select option using jquery

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
cgray1223
Asked:
cgray1223
1 Solution
 
Gurvinder Pal SinghCommented:
make it
$("#selectAlbum option[value='" + albumId + "']").remove();
0
 
sam2912Commented:
I believe you do not need the single quotes
$("#selectAlbum option[value=" + albumId + "]").remove();

Open in new window

0

Featured Post

Industry Leaders: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now