Blogger Information
Blog 28
fans 0
comment 0
visits 65163
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
两个bootstrap模态框,一个可以正常显示,另一个无法显示
蒸蒸
Original
799 people have browsed it

一、TP版本:5.1.41
二、要实现的功能:
通过jq,控制模态框的显示与隐藏
如果满足条件一:模态框一显示,模态框二隐藏
如果满足条件二:模态框二显示,模态框一隐藏
实现方法:
1.两个模态框外层都添加一个div
2.加上一句jq代码:jQuery.noConflict();

  1. <button id='showmodal' type="button" class="btn btn-xs" data-toggle="modal" data-target="#myModal">打开模态框1</button>
  2. <button id='showmodalt' type="button" class="btn btn-xs" data-toggle="modal" data-target="#myModalt">打开模态框2</button>
  3. <!-- 模态框1 -->
  4. <div>
  5. <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  6. 省略部分代码.....
  7. </div>
  8. </div><!-- 模态框1外层的div -->
  9. <!-- 模态框2 -->
  10. <div>
  11. <div class="modal fade" id="myModalt" tabindex="-1" role="dialog" aria-labelledby="myModalLabel_t" aria-hidden="true">
  12. 省略部分代码.....
  13. </div>
  14. </div><!-- 模态框2外层的div -->
  15. <script>
  16. //加上这句
  17. jQuery.noConflict();
  18. $(document).ready(function (){
  19. var url=window.location.href;
  20. if(url.indexOf('flag=true')>-1){
  21. //关闭模态框2,打开模态框1
  22. $("#myModalt").modal('hide');
  23. $('#showmodal').trigger('click');
  24. }
  25. if(url.indexOf('flag=false')>-1){
  26. //关闭模态框1,打开模态框2
  27. $("#myModal").modal('hide');
  28. $('#showmodalt').trigger('click');
  29. }
  30. });
  31. </script>

百度有的人只加外层div就可以,有的人只需要加jQuery.noConflict();而我的必须两个都加,才能正常运行;目前尚不明白其中的原理和原因

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post