如何让父母可点击?

时间:2017-07-18 05:36:07

标签: twitter-bootstrap

我试过多次点击父li。我正在使用bootstrap简单下拉列表,但主要的第一个li链接没有打开。任何人都可以帮助我吗?

<ul class="nav navbar-nav">
        <li class="dropdown">
        <!--This Link Is not Working-->  <a href="/india-tour-packages/" target="_blank" class="dropdown-toggle" data-toggle="dropdown">India Tour Package<b class="caret"></b></a> 
          <ul class="dropdown-menu">
          <li><a href="/india-tour-packages/golden-triangle-tour-packages/">Golden Triangle Tours</a></li>
<li><a href="/india-tour-packages/rajasthan-tour-packages/">Rajasthan Tour Packages</a></li>
<li><a href="/india-tour-packages/south-india-tour-packages/">South India Tour Packages</a></li>
<li><a href="/india-tour-packages/north-india-tour-packages/">North India Tours</a></li>
<li><a href="/india-tour-packages/">View all</a></li>

          </ul>
        </li>

1 个答案:

答案 0 :(得分:0)

如果您只想让父li可点击,您可以执行以下操作。请让我知道你要做什么。

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>IndexStackOverflow900</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $(".dropdown").click(function () {
                alert("you clicked on parent li");
            })
        })
    </script>
</head>
<body>
    <ul class="nav navbar-nav">
        <li class="dropdown">
            <!--This Link Is not Working-->  <a href="/india-tour-packages/" target="_blank" class="dropdown-toggle" data-toggle="dropdown">India Tour Package<b class="caret"></b></a>
            <ul class="dropdown-menu">
                <li><a href="/india-tour-packages/golden-triangle-tour-packages/">Golden Triangle Tours</a></li>
                <li><a href="/india-tour-packages/rajasthan-tour-packages/">Rajasthan Tour Packages</a></li>
                <li><a href="/india-tour-packages/south-india-tour-packages/">South India Tour Packages</a></li>
                <li><a href="/india-tour-packages/north-india-tour-packages/">North India Tours</a></li>
                <li><a href="/india-tour-packages/">View all</a></li>
            </ul>
        </li>
    </ul>
</body>
</html>