0
$("#EMPLOYEE_ALT option:[value='"+$("#EMPLOYEE_ID").val()+"']").remove();

the above code gives the following error:

Uncaught Error: Syntax error, unrecognized expression: #EMPLOYEE_ALT\ option:[value='9999']

9999 is employee id witch is correct and this value suppose to be sent via ajax and return with something.

$.post("url", { emp: $("#EMPLOYEE_ID").val(),ajax: "yes"  },
2
  • 1
    Seems TYPO, voting to close Commented Apr 11, 2017 at 11:48
  • typographical error :- you have unexpected : with your selector Commented Apr 11, 2017 at 11:52

2 Answers 2

1

You have unexpected : in your selector. The correct selector would be

$("#EMPLOYEE_ALT option[value='"+$("#EMPLOYEE_ID").val()+"']").remove();
Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

"#EMPLOYEE_ALT option[value='"+$("#EMPLOYEE_ID").val()+"']"

The attribute selector doesn't haves : on it. That is used for CSS's pseudo-classes only.

$("#remove").on("click", function() {
    $("#EMPLOYEE_ALT option[value='9999']").remove();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<select id="EMPLOYEE_ALT">
  <option value="1">1</option>
  <option value="9999">9999</option>
</select>

<button id="remove">Remove item '9999'</button>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.