css - 如何隐藏 div onload 并需要在单击按钮时显示?

标签 css

我需要隐藏一个 div onload 并且需要在点击按钮时访问这个 div

<input id="abcd" type="button" value="display" />
<div id="xyz" style="height:600px;width:1000px;background-color:black">
    <div style="height: 350px; width: 250px; background-color: red; float: right;margin-right:30px;margin-top:100px;">
        <h1>Charaacters</h1>
    </div>
    <div style="height: 350px; width: 250px; background-color: green; float: left; margin-left: 30px; margin-top: 100px; ">
        <h1>Translated Words</h1>
    </div>
    <div style="height: 350px; width: 250px; background-color: yellow; float: left; margin-left: 100px; margin-top: 100px; ">
        <h1>Translation</h1>
        <input type="text" />
        <input type="button" value="trans" />
    </div>
</div>

这是我的脚本,但它不起作用

    $(document).ready(function () {
        $("#xyz").hide();
        $("#abcd").click(function () {
        $("#xyz").hide();
        });
    });
</script>

最佳答案

您在按钮点击功能中使用了hide(),请将其更改为show()

 $(document).ready(function () {
        $("#xyz").hide();
        $("#abcd").click(function () {
        $("#xyz").show(); //This should be show
        });
    });

在这里查看工作 fiddle :“https://jsfiddle.net/gpfzassv/

关于css - 如何隐藏 div onload 并需要在单击按钮时显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31376953/

相关文章:

javascript - 我应该提交由 laravel mix 生成的 css 和 js 吗?

javascript - 如何为每个div追加div

html - 部分未显示在打印预览中?

css - 如何使用CSS打破颜色

html - 书籍封面图像旁边的章节列表

html - 显示特定 SPAN 下面的内容

css - 如何从数组中选取随机内容

php - 用自定义图像替换 WooCommerce 属性标签

javascript - CSS Transitions 与 JS 动画包的性能

html - 如何使用 bootstrap 将 <h1> 垂直和水平居中