我正在尝试使用 jQuery UI 为表单上的过渡设置动画,虽然代码在 Firefox 和 Chrome 中正常工作,但在 IE8 中出现 Javascript 错误。
我正在使用 jquery-ui-1.8.2.custom.min.js,给出的错误是:
Message: 'end.0' is null or not an object - Line: 819 - Char: 6
我的 CSS:
.formfield {
background-color: White;
border: none;
padding: 5px;
width: 90%;
overflow: hidden;
margin: 0px;
}
.formfieldselected {
background-color: MintCream;
border: none;
padding: 5px;
margin: 0px;
overflow: hidden;
}
Javascript:
$(document).ready(function()
{
$(":input").each(function()
{
var myInput = $(this);
if (this.type == 'submit')
{
return;
}
myInput.bind('focusin', function()
{
$('#' + this.id + 'field').removeAttr('style'); // Reset Style if broken
$('#' + this.id + 'field').switchClass('formfield', 'formfieldselected', 300);
$('#' + this.id + 'helpbox').removeClass('helpboxhidden').addClass('helpboxvisible');
});
myInput.bind('focusout', function()
{
$('#' + this.id + 'field').switchClass('formfieldselected', 'formfield', 300);
$('#' + this.id + 'helpbox').removeClass('helpboxvisible').addClass('helpboxhidden');
});
});
...
}
最后,这段代码应该处理的元素之一:
<DIV id="eventnamefield" class="formfield">
<DIV id="eventnamehelpbox" class="helpboxhidden">
This name is used throughout the system to refer to this event and is shown to Attendees
</DIV>
<label for="eventname" class="adminformlabel">Event Name:</label>
<br />
<input type="text" name="eventname" value="" id="eventname" maxlength="50" class="adminforminput" />
</DIV>
最佳答案
找到答案。
事实证明,IE 下的 jQuery UI 无法处理按名称引用的颜色。在 CSS 中将颜色更改为十六进制代码解决了这个问题。
关于javascript - jQuery UI switchClass 在 IE8 下失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3276661/