如果javascript已关闭,则使显示/隐藏可访问 [英] make show/hide accessible if javascript is off

查看:116
本文介绍了如果javascript已关闭,则使显示/隐藏可访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$(document).ready(function(){ 
    $("#CO_createAccount").click( function (){ 
        if(this.checked){
            $(".CO_accountForm").show();  
        } else {
            $(".CO_accountForm").hide();  
        }
    });
});

并且我将".CO_accountForm"的css设置为"display:none;"

and I have the css set for ".CO_accountForm" set to "display:none;"

但是,如果关闭javascript,我希望隐藏元素可见.我想我可以通过在上面添加一个隐藏的类来做到这一点,但是我将如何处理呢?

But, I want the hidden element to be visible if javascript is turned off. I assume I can do this by adding a hidden class the above, but how would I go about this?

谢谢!

推荐答案

删除".CO_accountForm"display:none属性,而是通过document.ready事件中的javascript隐藏/设置display:none属性.

Remove the display:none attribute for the ".CO_accountForm" and instead hide/set the display:none attribute via javascript in the document.ready event.

即:

$(document).ready(function(){      
    // hide the form using JS so that if the browser 
    // doesn't support JS then the form is always displayed.
    $(".CO_accountForm").hide(); 
    $("#CO_createAccount").click( function (){          
        if(this.checked){             
            $(".CO_accountForm").show();           
        } else {             
            $(".CO_accountForm").hide();           
        }     
    }); 
}); 

这篇关于如果javascript已关闭,则使显示/隐藏可访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆