0
所以我的困惑是Scrollspy是針對外部的div而不是它正在修改的實際元素。我試圖去了解爲什麼就是這樣?爲什麼Scrollspy的目標是外部div而不是ul?
有問題的代碼行12和89-90在這裏:
http://4f7ba83874222b00ae84-8c55136fa379d9b2d1adde446f45d068.r28.cf2.rackcdn.com/scrollspy.html
盡我所能,包括這裏相關部分:
<body data-spy="scroll" data-target="#myScrollspy">
<div class="container">
<div class="row">
<div class="col-xs-10 col-sm-10 col-md-10 col-lg-10">
<h1 id="p_1">Part 1</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut et felis consequat velit sollicitudin fermentum....
</p>
<h1 id="p_2">Part 2</h1>
<p>
Maecenas massa eros, aliquam id nisi ut, venenatis eleifend diam....
</p>
<h1 id="p_3">Part 3</h1>
<p>
Quisque id luctus tortor, a scelerisque nulla....
</p>
<h1 id="p_4">Part 4</h1>
<p>
Nam sed volutpat sapien....
</p>
</div>
<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2" id="myScrollspy">
<ul class="nav nav-pills nav-stacked affix">
<li class="active"><a href="#p_1">Part 1</a></li>
<li><a href="#p_2">Part 2</a></li>
<li><a href="#p_3">Part 3</a></li>
<li><a href="#p_4">Part 4</a></li>
</ul>
</div>
</div>
</div>
</body>
那麼Bootstrap如何知道哪個是哪個?它是否搜索DOM樹? – newbsie