简体   繁体   English

Bootstrap Modal没有显示

[英]Bootstrap Modal not showing up

Im trying to open a modal when an image is clicked with this code: 我试图用以下代码单击图像时打开模式:

<a href="#" data-toggle="modal" data-target="#download"><img class="featurette-image pull-right" src="http://i.imgur.com/96C9Nij.png"></a>
<div class="modal fade" id="download" tabindex="-1" role="dialog" aria-labelledby="downloadlabel" aria-hidden="true">
<div class="modal-dialog">
  <div class="modal-content">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
      <h4 class="modal-title" id="downloadlabel">Download & Install Pixelmon</h4>
    </div>
    <div class="modal-body">
    <p>
      <strong>Installing Pixelmon</strong><br /><br />
    First, you'll need to install Forge, so simply double-click "minecraftforge-installer-x.x.x-x.xx.x.xxx" and a menu will pop up for you to install forge. 
    </p>
    <p>
    Once you have done that its recommended you open the minecraft launcher, create a new profile, and select the forge version from the version dropdown.<br>After this launch minecraft and check if forge is running properly.
    </p>
    <p>
    Now that forge is installed, you only have to copy "Pixelmon x.x.x.zip" to your %appdata%\roaming\.minecraft\mods folder.
    </p>
    <p>
    You will need to use the previously created profile ( the forge profile ) to play with Pixelmon.
    </p>
    <p>
    Now that you have Pixelmon installed, you may beggin your adventure on play.pokemasters.org
    </p>
    </div>
    <div class="modal-footer">
      <a href="http://download1076.mediafire.com/2yznx31i1d6g/693cqta45ppv0la/ForgePixelmon2.5.2.zip" target="blank"><button type="button" class="btn btn-danger">Download Pixelmon</button></a>.
      <button type="button" class="btn btn-info" data-dismiss="modal">Close</button>
    </div>
  </div>
 </div>
</div>

The thing is its not appearing when I click the image. 问题是当我单击图像时它没有出现。

Have you tried, $('#download').modal("show"); 您是否尝试过$('#download').modal("show"); ?

There are more than one way to show or popup your modal. 有多种方法可以显示或弹出模态。

  • You can show your modal with out using script or onclicks. 您可以不使用脚本或onclick来显示模态。

Here is the Example: 这是示例:

<a href="#" data-toggle="modal" data-target="#download">

Now in modal give id same as you wrote in data-target which is already done in your code 2nd use class="popup" instead of your current class, 现在,在模式中给出与在数据目标中编写的相同的id,这已经在代码2中完成了。使用class =“ popup”代替当前的类,

<div id="download" class="popup">Your modal items/elements </div>

this approach will ease you with extra coding and time. 这种方法将使您节省额外的编码和时间。

  • You can also show or popup your modal with the use of onclick property, 您还可以使用onclick属性显示或弹出模态,

here is an Example: 这是一个例子:

<a href="#" onclick="showmodal()" data-toggle="modal" data-target="#download">

Modal 语气

<div id="download" class="popup">Your modal items/elements </div>

Script here just call your modal by id with .modal property to show or popup. 此处的脚本只需使用.modal属性通过id调用您的模态即可显示或弹出。

 function showmodal()
{
$("#download").modal("show");
}

I hope it will help you and others in future. 希望以后对您和其他人有帮助。

Tip :You can use both data-target and onclick for one modal as well. 提示 :您也可以将data-target和onclick都用于一种模式。

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

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