javascript - jQuery UI switchClass 在 IE8 下失败

标签 javascript jquery-ui internet-explorer-8 colors

我正在尝试使用 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/

相关文章:

javascript - 如何在 js 数组中搜索?

javascript - 在 jQueryUI 中拖动一个按钮

jquery - 使用 jquery 选中/取消选中复选框?

css - 我使用悬停的 css 工具提示在 IE8 上不起作用

css - 在兼容模式下,IE7 和更低版本的这种条件 css 加载是否适用于 IE8?

javascript - 如何更改IE8中TextNode的textContent?

javascript - 单击网页中的选项时如何从 "id"向下移动一些像素?

javascript - Dojo.NodeList.append()

javascript - Paypal Braintree pop 在 chrome 中被屏蔽

jquery - 对话框运行 1 秒后消失?