0

下面的语句怎么写

if ($('#SelectedItems option[value=' + optionData.Value + ']').length === 0) ;

使用变量

var selectedItems = $('#SelectedItems');

//Something like this but not exactly

if ($(**selectedItems** + "option[value=' + optionData.Value + ']").length === 0) ;
4

3 回答 3

0
if ($('option[value="' + optionData.Value + '"]',$('#SelectedItems')).length === 0) 
于 2012-09-09T05:27:44.533 回答
0

我想你想要这个

if ($("option[value='" + optionData.Value + "']", selectedItems).length === 0)

selectedItems这将选择与选择器匹配的元素的所有后代"option[value='" + optionData.Value + "']"

于 2012-09-09T05:27:55.623 回答
0

if (selectedItems.find("option[value='" + optionData.value + "']").length === 0) 应该做你正在寻找的东西。

于 2012-09-09T05:28:15.327 回答