$().ready(function () {
$('#remove').click(function () {
return !$('#FeatureLists option:selected').remove();
});
$("#add").click(function () {
var vals = $("#txtaddfeature").val();
if (vals != '')
$("#FeatureLists").prepend("<option value=" + vals + " selected='selected'>" + vals + "</option>");
$("#txtaddfeature").val() = ""
});
});
The thing is that if I enter Add it will go into the option without any problem, but if I enter Manage People only Manage will go as there is a space gap between Manage and People . How will I solve this bug?
Following up from what Simon Thompson said, you need to put the attributes in quotes. Also, it’s good practice to use single quotes in javascript, so that you can use double quotes in attribute values. Also, you can’t set the result of a function call (
$("#txtaddfeature").val() = "").