3

当使用此代码单击图像时,我尝试打开模式:

<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>

当我单击图像时,它没有出现。

4

2 回答 2

5

你试过$('#download').modal("show");吗,

于 2013-11-12T11:21:29.023 回答
2

显示或弹出模式的方法不止一种。

  • 您可以在不使用脚本或 onclicks 的情况下显示您的模式。

这是示例:

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

现在在模态中给出与您在数据目标中编写的相同的 id,这已经在您的代码中完成第二次使用 class="popup" 而不是您当前的类,

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

这种方法将通过额外的编码和时间来减轻您的负担。

  • 您还可以使用 onclick 属性显示或弹出模式,

这是一个例子:

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

模态

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

此处的脚本只需通过带有 .modal 属性的 id 调用您的模态来显示或弹出。

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

我希望它对您和其他人将来有所帮助。

提示:您也可以将 data-target 和 onclick 用于一种模式。

于 2016-08-10T01:48:43.967 回答