我正在使用以下代码,正如您所看到的,我选择仅在未选择第7个td元素的select字段时执行操作。即便如此,在页面加载时选择值时也会执行代码。
我必须做些什么来确保其正常工作吗?
if (jQuery("div.amfinder-horizontal td:nth-child(7) select").is(':visible') && jQuery('div.amfinder-horizontal td:nth-child(5) select option:selected').length > 0 && jQuery('div.amfinder-horizontal td:nth-child(7) select option:not(:selected)')) {
setTimeout(function() {
jQuery("div.amfinder-horizontal td:nth-child(6) select option").each(function() { this.selected = (this.text == "<?php echo Mage::registry('current_category')->getName(); ?>"); });
jQuery("div.amfinder-horizontal td:nth-child(6) select option").change();
$('finder-4023--20454').simulate('click'); // This is the ID of the select element ( it is the same as div.amfinder-horizontal td:nth-child(6) select )
$('finder-4023--20454').simulate('change'); // This is the ID of the select element ( it is the same as div.amfinder-horizontal td:nth-child(6) select )
console.log('Changed!');
}, 700);
jQuery("#popover6").show();
}
谢谢!