【发布时间】:2012-09-11 14:49:49
【问题描述】:
我有代码(根据 Brad Christie 的建议进行了编辑):
drupal_add_js('
jQuery(document).ready(function(){
jQuery("#selFinishes option").each(function(index) {
if (jQuery(this).val() == ' . $filter_color . ') {
jQuery(this).attr("selected","selected")
}
})
});
', "inline");
它成功地将“selected”属性($filter_color 通过 PHP 添加)添加到选定值。但是当我像这样定位多个选择字段时:
drupal_add_js('
jQuery(document).ready(function(){
jQuery("#selFinishes option").each(function(index) {
if (jQuery(this).val() == ' . $filter_color . ') {
jQuery(this).attr("selected","selected")
}
})
jQuery("#selThemes option").each(function(index) {
if (jQuery(this).val() == ' . $filter_theme . ') {
jQuery(this).attr("selected","selected")
}
})
});
', "inline");
两个循环都无法工作!
感谢您的提示!
【问题讨论】: