I want to hide a div if javascript is turned off and show that div if javascript enabled but I don't want to use <noscript> as in chrome and opera it has some issues. So what I am doing is something like this:

我想隐藏一个div如果关闭javascript并显示div如果启用javascript但我不想使用

<div id="box" style="display:none"></div>
<script type="text/javascript">
document.getElementById("box").style.visibility = "visible";
</script>

But the javascript part does not show the div. How can I make it visible is javascript is enabled. Also tried $('#box').show(); but that too didn't work.

但是javascript部分没有显示div。如何启用javascript,我怎样才能看到它。还试过$('#box')。show();但那也行不通。

6 个解决方案

#1


7

Use style.display

使用style.display

document.getElementById("box").style.display = "block";

更多相关文章

  1. 等待执行所有ajax回调的最佳解决方案
  2. 【问题解决方案】ImportError: No module named 'pygal'
  3. Python 黏包及黏包解决方案
  4. 无法安装ndg-httpsclient或者我的解决方案错误
  5. Linux无法连接网络解决方案
  6. Media-S 简介(一个开源的DRM解决方案)
  7. AppScan安全问题解决方案
  8. PLSQL乱码解决方案
  9. 数据库不支持中文解决方案(mysql)

随机推荐

  1. 分布式作业系统 Elastic-Job-Cloud 源码
  2. 分布式作业 Elastic-Job-Lite 源码分析
  3. VMWare 添加新磁盘,并挂载
  4. RocketMQ 安装
  5. 分布式作业系统 Elastic-Job-Cloud 源码
  6. 注册中心 Eureka 源码解析 —— EndPoint
  7. 分布式作业系统 Elastic-Job-Cloud 源码
  8. 分布式作业系统 Elastic-Job-Lite 源码分
  9. 注册中心 Eureka 源码解析 —— 网络通信
  10. 消息中间件 RocketMQ 源码解析 —— 调试