简体   繁体   English

打开2个模态窗口js

[英]Open 2 modal windows js

Can you please tell me how to open the second modal window? 您能告诉我如何打开第二个模式窗口吗? Now open when you click on different links open the same window. 现在,当您单击不同的链接时,将打开同一窗口。 Tell me please. 请告诉我。 How to make a distinction between them. 如何区分它们。 Please help code. 请帮助代码。 And I honestly do not understand what details can be clarified, but stackoverflow.com does not allow to save the question. 老实说,我不知道可以澄清哪些细节,但是stackoverflow.com不允许保存问题。

 function send($i) { $("#div1").load("prod.php/?id_prod=" + $i); } function show(state) { document.getElementById('window').style.display = state; document.getElementById('wrap').style.display = state; } 
 #wrap { display: none; opacity: 0.8; position: fixed; left: 0; right: 0; top: 0; bottom: 0; padding: 16px; background-color: rgba(1, 1, 1, 0.725); z-index: 100; overflow: auto; } #window { width: 400px; height: 400px; margin: 50px auto; display: none; background: #fff; z-index: 200; position: fixed; left: 0; right: 0; top: 0; bottom: 0; padding: 16px; border-radius: 5px; } 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <a onclick="send('25');show('block');" style='text-decoration:none;color:#000;cursor:pointer;'>Open window</a> <div onclick="show('none')" id="wrap"></div> <div id="window"> <img class="close" onclick="show('none')" src="http://sergey-oganesyan.ru/wp-content/uploads/2014/01/close.png"> <div id="div1"> Window 1 </div> </div> <a onclick="send('25');show('block');" style='text-decoration:none;color:#000;cursor:pointer;'>Open window 2</a> <div onclick="show('none')" id="wrap"></div> <div id="window"> <img class="close" onclick="show('none')" src="http://sergey-oganesyan.ru/wp-content/uploads/2014/01/close.png"> <div id="div1"> Window 2 </div> </div> 

I agree with @aaaaane but your approach is not true. 我同意@aaaaane,但您的做法不正确。 You should check about javascript promise methods or async callback operations. 您应该检查有关javascript promise方法或异步回调操作的信息。

You can't know response time of server and your modal will be empty until response. 您不知道服务器的响应时间,您的模式将一直为空,直到响应。

Also you must use one method on <a> tag for understandable. 另外,您必须在<a>标记上使用一种方法才能理解。 like this; 像这样;

<a onclick="someMethod(25)">Button</a>

Just had to change the id of one of the elements. 只需更改元素之一的id。 The id must be always unique. ID必须始终是唯一的。

 function send($i) { $("#div1").load("prod.php/?id_prod=" + $i); } function show(state, id) { document.getElementById(id).style.display = state; document.getElementById('wrap').style.display = state; } 
 #wrap { display: none; opacity: 0.8; position: fixed; left: 0; right: 0; top: 0; bottom: 0; padding: 16px; background-color: rgba(1, 1, 1, 0.725); z-index: 100; overflow: auto; } .window { width: 400px; height: 400px; margin: 50px auto; display: none; background: #fff; z-index: 200; position: fixed; left: 0; right: 0; top: 0; bottom: 0; padding: 16px; border-radius: 5px; } 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <a onclick="send('25');show('block', 'window');" style='text-decoration:none;color:#000;cursor:pointer;'>Open window</a> <div onclick="show('none')" id="wrap"></div> <div id="window" class='window'> <img class="close" onclick="show('none', 'window')" src="http://sergey-oganesyan.ru/wp-content/uploads/2014/01/close.png"> <div id="div1"> Window 1 </div> </div> <a onclick="send('25');show('block', 'window-2');" style='text-decoration:none;color:#000;cursor:pointer;'>Open window 2</a> <div onclick="show('none')" id="wrap"></div> <div id="window-2" class='window'> <img class="close" onclick="show('none', 'window-2')" src="http://sergey-oganesyan.ru/wp-content/uploads/2014/01/close.png"> <div id="div1"> Window 2 </div> </div> 

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

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