为什么这个引导下拉示例工作? [英] Why doesn't this bootstrap dropdown example work?

查看:114
本文介绍了为什么这个引导下拉示例工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是试着在Bootstrap文档的例子,但它似乎并不工作。我只是得到纯HTML。这是我的代码:

I'm just trying out the example in Bootstrap documentation, but it doesn't seem to work. I just get plain HTML. This is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="bootstrap.css" type="text/css">
<script type="text/javascript" src="http://twitter.github.com/bootstrap/assets/js/bootstrap-dropdown.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>

$('.dropdown-toggle').dropdown();


</script>
<title>Dropdown</title>
</head>

<ul class="nav nav-pills">
  <li class="active"><a href="#">Regular link</a></li>
  <li class="dropdown" id="menu1">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#menu1">
      Dropdown
      <b class="caret"></b>
    </a>
    <ul class="dropdown-menu">
      <li><a href="#">Action</a></li>
      <li><a href="#">Another action</a></li>
      <li><a href="#">Something else here</a></li>
      <li class="divider"></li>
      <li><a href="#">Separated link</a></li>
    </ul>
  </li>
  ...
</ul>

</body>
</html>

有没有人看到问题?感谢。

Does anyone see the problem? Thanks.

推荐答案

我发现您的标记有两个问题。

I see two problems with your markup.

首先,你包括引导插件之前的jquery插件。

First, you're including the bootstrap plugin "before" the jquery plugin. Jquery first, bootstrap plugins second.

其次,您使用的DOCTYPE不受引导程序支持,您必须使用HTML5的DOCTYPE:

Second, you're using a DOCTYPE that is not supported by the bootstrap, you have to use HTML5's DOCTYPE:

<!DOCTYPE html>

这篇关于为什么这个引导下拉示例工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆