gpt4 book ai didi

jQuery代码removeAttr问题

转载 作者:行者123 更新时间:2023-12-01 08:23:44 27 4
gpt4 key购买 nike

<input id="mnc" type="text"/>
<input type="text" id="selected" />
<小时/>
$('#mnc').val().length ? $('#selected').attr({
'size': $('#mnc').val()
}) : $('#selected').removeAttr('size');

这在 Firefox 4 中会出现错误。

Index or size is negative or greater than the allowed amount" code: "1

即使属性不存在,其他浏览器也能够处理removeAttr。我正在做的是检查输入 #mnc 是否为空,然后从 #selected 中删除属性大小,无论它是否存在。

检查http://jsfiddle.net/zFCtU/1/

最佳答案

这是 Firefox 中的一个错误,请参阅 jQuery bug report 。对于 jQuery 版本 >= 1.6 应该有一个解决方法。

编辑:遗憾的是该修复将在 1.6 版本中发布(而不是我之前写的 1.5.2)。 Firefox 4.0.1 应该在 Firefox 端修复它。您要么必须决定安装 4.0.1,要么必须自己应用补丁。

关于jQuery代码removeAttr问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5642742/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com