【发布时间】:2016-08-02 17:06:17
【问题描述】:
这是实际内容。在下面的代码中,在 UI 中的下拉列表中添加了两次值。将下拉值显示为“AprilApril”而不是“April”
if ($('#dk_container_selectToYear .dk_options li.dk_option_current a').text() == 2016) {
var currentdate = new Date();
var month = currentdate.getMonth();
var monthname = monthLookup[currentdate.getMonth()];
month = month + 3;
while (month <= 13) {
$('#dk_container_selectToMonth .dk_options li:nth-child(' + month + ')').css({ "display": 'none' });
var listvalue = $('#dk_container_selectToMonth .dk_options li:nth-child(' + month + ')').text();
if ($('#dk_container_selectToMonth .dk_options li.dk_option_current a').text() == listvalue) {
$('#selectToMonth').dropkick('reset');
$('#selectToMonth').dropkick('setValue', monthname);
}
month++;
}
}
$('#selectToMonth').dropkick('setValue', monthname);
是否有其他选择可以避免它..
提前谢谢..
【问题讨论】:
-
monthLookup 是什么样的?
-
如果你在设置后控制台日志
monthname,你会看到什么?
标签: javascript jquery duplicates setvalue