作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
另一个复选框问题。我的列表中有项目。每个项目都有一个复选框。我想要做的是勾选列表中的FIRST项目的复选框。没错,由于 checked="checked"
,它已经勾选了所有复选框。
{% for item in items %}
<tr class="items_table_row">
<td><input type="checkbox" name="{{item.pk}}" value="{{item.pk}}" checked="checked"></td>
<td>{{item.tiptop_id}}</td><td>{{item.alternative_id}}</td><td>{{item.title}}</td><td>{{item.type}}</td><td>{{item.format}}</td>
<td><span id="{{item.pk}}" name="type">{{item.itemstatushistory_set.latest}}</span></td><td>{{item.itemstatushistory_set.latest.date.date|date:"d M Y"}}</td>
<td><a href="{% url tiptop.views.edit_item item.client.pk item.pk %}" onclick="return showAddAnotherPopup(this);">Edit</a></td>
</tr>
{% endfor %}
最佳答案
您可以将选中的属性添加到第二个项目,如下所示:
{% ifequal forloop.counter 2 %} checked="checked"{% endifequal %}
默认的forloop.counter
是1索引的,或者您可以专门使用0索引的计数器:
forloop.counter0
关于python - Django 复选框只想选中第一个框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4864481/
我目前在我的 master 分支上。我需要 CSS 方面的帮助,但不幸的是我的网站受身份验证保护。这使得其他人很难来我的站点进行调试。我计划开始一个新的分支,fixing_css,第一次提交删除所有身
我是一名优秀的程序员,十分优秀!