重现错误:http://jsfiddle.net/rkw79/mmBKf/2/
>在列表框中选择一个项目
>点击UL中的该项目,它将消失,列表框将显示为未选中
>单击列表框中的相同项目
请注意,事件已触发,但未添加该项
现在执行相同的步骤,除了使用.prop(‘selected’,”)而不是.removeProp(‘selected’):http://jsfiddle.net/rkw79/mmBKf/3/
解决方法
With some built-in properties of a DOM element or window object,browsers may generate an error if an attempt is made to remove the property. jQuery first assigns the value undefined to the property and ignores any error the browser generates. In general,it is only necessary to remove custom properties that have been set on an object,and not built-in (native) properties.
Note: Do not use this method to remove native properties such as checked,disabled,or selected. This will remove the property completely and,once removed,cannot be added again to element. Use
.prop()
to set these properties tofalse
instead.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。