这个密码怎么了?当选项已经被选中时,我想从select中删除一个选项(存储在变量中)。我从控制台接收到此错误:
未识别错误:语法错误,未识别表达式: select.nuevaDescripcionProducto optionvalue=Aspiradora Industrial
到目前为止,这就是我所拥有的:
$(".formularioVenta").on("change", "select.nuevaDescripcionProducto", function() {
var nombreProducto = $(this).val();
$("select.nuevaDescripcionProducto option[value="+nombreProducto+"]").remove();如果有人知道,请告诉我.
发布于 2020-09-13 22:47:13
值需要额外的引号,因为字符串中有一个空格。
$("select.nuevaDescripcionProducto option[value='"+nombreProducto+"']").remove();
// ^^ single quotes ^^或者作为替代使用filter()
$("select.nuevaDescripcionProducto").children().filter((_,op)=> op.value===$(this).val()).remove()https://stackoverflow.com/questions/63876248
复制相似问题