简体   繁体   English

Twitter Bootstrap Dismiss按钮不起作用

[英]Twitter Bootstrap Dismiss Button not Working

I am trying to use Twitter Bootstrap to create a website detailing the statistics of Minecraft servers, to make it easy for my users to know which server is online. 我正在尝试使用Twitter Bootstrap创建一个详细描述Minecraft服务器统计数据的网站,以便我的用户轻松了解哪个服务器在线。 However, when I use the alert component in Twitter Bootstrap, I cannot dismiss the alert. 但是,当我在Twitter Bootstrap中使用警报组件时,我无法解除警报。 Here is my code: 这是我的代码:

<!DOCTYPE html>

<title>Dillon's Minecraft Servers</title>

<ul class="nav nav-tabs">
    <li><a href="index.htm">Home</a></li>
    <li class="active"><a href="#">Vanilla</a></li>
    <li><a href="ftb.htm">Feed the Beast</a></li>
    <li><a href="bigdig.htm">Big Dig</a></li>
</ul>

<div class="hero-unit">
    <h2>Vanilla</h2>
    <p>The Vanilla server runs just plain Minecraft. It has some advanced features like Mob Arenas, anti-cheat, and MMO-like leveling.</p>
</div>

<div class="alert">
<a href="#" class="close" data-dismiss="alert">&times;</a>
    <strong>Warning!</strong> This server is currently offline.
</div>

Never mind. 没关系。 I found my problem. 我发现了我的问题。 I forgot add the jquery script to the header. 我忘了将jquery脚本添加到标题中。 Sorry about that. 对于那个很抱歉。

Have you considered using a <button> rather than an <a> . 您是否考虑使用<button>而不是<a> That's what I did on my Bootstrap page as I was having a similar problem. 这就是我在Bootstrap页面上所做的,因为我遇到了类似的问题。 Doesn't fix that problem but it is a valid way round 不能解决这个问题,但它是一种有效的方法

<button type="button" class="close" data-dismiss="alert">&times;</button>

确保在button.js之前加载了jquery.min.js!

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

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