Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript html css jquery模式不';无法在浏览器中打开_Javascript_Jquery_Html_Css_Modal Dialog - Fatal编程技术网

Javascript html css jquery模式不';无法在浏览器中打开

Javascript html css jquery模式不';无法在浏览器中打开,javascript,jquery,html,css,modal-dialog,Javascript,Jquery,Html,Css,Modal Dialog,我试图创建一个模式窗口时,一个按钮被点击注册用户。我不知道是什么问题。按钮被单击,但模式窗口未打开。我的代码是这样的 创造 奥莫代尔先生{ 显示:无; 位置:固定; 溢出:自动; z指数:1; 左:0; 排名:0; 宽度:100%; 身高:100%; 背景颜色:灰色; } .模态内容{ 背景色:蜜露; 利润率:15%; 填充:20px; 边框:1px实心#888; 宽度:80%; } 您忘记添加单引号: <button type="button" onclick="document.g

我试图创建一个模式窗口时,一个按钮被点击注册用户。我不知道是什么问题。按钮被单击,但模式窗口未打开。我的代码是这样的


创造
奥莫代尔先生{
显示:无;
位置:固定;
溢出:自动;
z指数:1;
左:0;
排名:0;
宽度:100%;
身高:100%;
背景颜色:灰色;
}
.模态内容{
背景色:蜜露;
利润率:15%;
填充:20px;
边框:1px实心#888;
宽度:80%;
}

您忘记添加单引号:

<button type="button" onclick="document.getElementById('mymodal').style.display='block'">....
。。。。

如果插入了jquery,则可以使用它

您可以简单地为按钮提供一个ID,然后使用以下代码:

 <div class="button">
      <button type="button" id="open-modal" ">Create</button>


      <div id="mymodal" class="ourmodal">
        <div class="modal-content">

            <button id="close-modal">close</button>
        </div>
      </div>
    </div>

@拉姆kc

请尝试以下代码:


创造
奥莫代尔先生{
显示:无;
位置:固定;
溢出:自动;
z指数:1;
左:0;
排名:0;
宽度:100%;
身高:100%;
背景颜色:灰色;
}
.模态内容{
背景色:蜜露;
利润率:15%;
填充:20px;
边框:1px实心#888;
宽度:80%;
}
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

      <script>
        jQuery('#open-modal').on('click',function(){
            jQuery('#mymodal').show();
        });
        jQuery('#close-modal').on('click',function(){
            jQuery('#mymodal').hide();
        });
      </script>