简体   繁体   English

IE6中的jQuery按钮显示

[英]jQuery button display in IE6

We have some HTML buttons which we format using JQuery - $('#button').button() . 我们有一些HTML按钮,可以使用JQuery- $('#button').button()格式化。

Works great but.. when the page first loads in IE6 you see the "unformatted" regular HTML button and then you see the JQuery formatting kick in a split second or so afterwards. 效果很好,但是当页面首次在IE6中加载时,您会看到“未格式化的”常规HTML按钮,然后很快就会看到JQuery格式设置。

What can you do do avoid displaying the default HTML button and just display the JQuery formatted version? 您应该怎么做才能避免显示默认的HTML按钮,而只显示JQuery格式的版本?

Put it in a div which by default it hidden CSS: #hiddenDiv {display: none;} and then after you perform all of the styling on the button using jQuery unhide the div $('#hiddenDiv').show() 将其放在div中,默认情况下它会隐藏CSS: #hiddenDiv {display: none;} ,然后在使用jQuery对按钮执行所有样式之后,取消隐藏div $('#hiddenDiv').show()

Edit: To allow the button to be displayed when javascript is disabled: 编辑:要在禁用javascript时显示按钮,请执行以下操作:

<noscript>
    <style>
        #hiddenDiv
            {
            display: block!important;
            }
    </style>
</noscript>

Important: This will invalidate your HTML, as style tags are not allowed in noscript elements, and in XHTML noscript tags are not allowed in the head element. 重要提示:这将使您的HTML无效,因为noscript元素中不允许使用style标签,而head元素中也不允许在XHTML中使用noscript标签。

Try this out. 试试看 In your CSS code, write 在您的CSS代码中,编写

#button{
visibility: hidden
}

Put this code inside 将此代码放入

<!--[if IE 6]>
<![endif]-->

And in your $(document).ready function, add the following. 在$(document).ready函数中,添加以下内容。

("#button").css("visibility","visible");

Screw them if they use IE6 and disable Javascript. 如果他们使用IE6并禁用Javascript,请拧紧它们。 :P :P

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM