使用jQuery恢复到表单上的默认选项



我需要在magento上的搜索结果页面上恢复到表单上的默认选项。

我使用了下面的Jquery,它在firefox上运行良好。问题出在IE上。

<script type="text/javascript">
jQuery(document).ready(function(){
    jQuery('#form-validate-small option:selected').removeAttr('selected');
});
</script>

希望这是有意义的

感谢

这应该有效:

<script type="text/javascript">
jQuery(document).ready(function(){
    jQuery('#form-validate-small option:selected').removeAttr('selected');
    jQuery('#form-validate-small option:first-child').attr('selected', 'selected');
});
</script>

正在运行http://jsfiddle.net/VDw7B/3/

如果我理解正确,您不想使用具有的选项

selected='selected' 

如果是,请使用以下jQuery:

$('#foo').val(0);

try jQuery('#form validate small option:selected').attr('selected',false);


编辑

我在IE7上试过,发现它不起作用
应使用适当的属性
尝试,

jQuery('#form-validate-small option:selected').attr('checked', false);

最新更新