在IE6下,弹出脚本错误的提示:无法设置selected属性 未指明的错误
代码:selectObj.val(defaultSelect);//选中指定项
出现场景:动态填充select标签:为其添加option选项,之后设置默认项时出现
后期测试:发现并不一定出现,非常怪异,应该是还没有完全明白发生这个问题的时机
解决办法:
在设置selected属性的时候使用setTimeout函数设定一个任意时间即可
setTimeout(function(){
selectObj.val(defaultSelect);//选中指定项
},0);
IE 6 can throw an error "Error: Could not set the selected property. Unspecified error." when you try to manipulate select elements by adding options and then selecting one of your newly created items. I came across this while trying to use jQuery's .val() function to set the selected element after I had added some options to my select.
分享到:
相关推荐
ExtAspNet v2.2.1 ExtAspNet是一组专业的Asp.net控件库,拥有原生的AJAX支持和丰富的UI效果, 目标是创建没有JavaScript,没有... -在Page_Load中设置了哪些需要在AJAX中更新的Asp.net控件会在回发时保持状态,可以...
-修正绑定到Tree的XMLDocument中Icon属性映射错误(feedback:nopnop9)。 -修正HtmlEditor不能编辑的BUG(feedback:TheBox)。 -修正IE下有时会出现空白页面的情况(feedback:olivia919)。 +2009-12-06 v2.1.8 -...
- **设计方法**: 可以通过表单属性设置或使用设计工具中的模板选项来实现。 #### 9. 为 Web 定制“表单已处理”确认信息 - **定制方法**: 修改默认的确认信息,可以通过添加自定义脚本或使用`@MessageBox`函数来弹...
第6章(\代码\第06章) • sample01.htm 先使用后递增 • sample02.htm 先递增后使用 • sample03.htm 先使用后递减 • sample04.htm 先递减后使用 • sample05.htm 字符串...
在服务器端的脚本(如ASP)中,可以使用`REMOTE_HOST`来获取客户端IP: ```asp Request.ServerVariables("REMOTE_HOST") ``` 13. **元素投影**: CSS滤镜`filter`可以实现元素阴影效果,但请注意,这在现代...