【发布时间】:2013-09-09 20:51:18
【问题描述】:
如何检查我的数组中是否包含字符串?这是我将数组放在一起的方式...
// get the select
var $dd = $('#product-variants');
if ($dd.length > 0) { // make sure we found the select we were looking for
// save the selected value
var selectedVal = $dd.val();
// get the options and loop through them
var $options = $('option', $dd);
var arrVals = [];
$options.each(function(){
// push each option value and text into an array
arrVals.push({
val: $(this).val(),
text: $(this).text()
});
});
};
我想检查“Kelly Green”是否包含在数组中,如果我想 .show a li
$("#select-by-color-list li#kelly-green").show();
【问题讨论】:
标签: javascript jquery arrays