options [options.length]无效

时间:2015-05-05 09:29:48

标签: javascript jquery html attributes

我有jquery代码,它接受值并在数据库中更新它们。问题是它现在似乎无法正常工作。

它说:未捕获的TypeError:无法读取未定义的属性“长度”

以下是代码的一部分:

/superuser/needs/new/pants

1 个答案:

答案 0 :(得分:7)

options不是属性,是尝试

的属性
var options = $('#response_').prop('options');
var options = $('#response_')[0].options; //or

但您可以使用jQuery创建像

这样的选项
$('<option />',{text: response_title, value: r, selected: true}).appendTo('#response_');
相关问题