我正在尝试使用Bootstrap下拉菜单在我的应用中动态生成一个ID,但由于某种原因,它不会出现。
<div class="dropdown">
<button class="btn btn-secondary btn-sm btn-canvas dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Compare with
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
{% for i in team_list_pop %}
<a class="dropdown-item" id="{{i.first_name}}" href="#">{{i.first_name}} {{i.last_name}}</a>
{% endfor %}
</div>
</div>
和我在浏览器中进行检查时的输出
<a class="dropdown-item" href="#">John Doe</a>
没有ID的痕迹。我如何才能达到输出
<a id="john" class="dropdown-item" href="#">John Doe</a>
thx你非常
我认为您应该查看是否要输入的值,因为我在代码中执行了同样的事情,并且可以使用:
... id="{{ values.0.vat }}" onclick="callAjax.call(this)" ...
这是我在项目之一中使用的示例代码,它正确显示了Inspect中的ID。