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

cgray1223Asked:
Who is Participating?
 
Gurvinder Pal SinghConnect With a Mentor Commented:
make it
$("#selectAlbum option[value='" + albumId + "']").remove();
0
 
Samuel LiewCommented:
I believe you do not need the single quotes
$("#selectAlbum option[value=" + albumId + "]").remove();

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.