【发布时间】:2015-06-22 04:05:41
【问题描述】:
HTML
<form id="searchPersonForm" action="#" th:object="${person}" method="post">
<input type="text" class="form-control" id="person_id" th:field="*{person_id}"></input>
<input type="text" class="form-control" id="child_id" th:field="*{child_id}"></input>
</form>
如何分配动态 id,如 person_id_100、person_id_200... 和 child_id_100、child_id_200... 值 100、200 是实际的 person_id。
我们可以不用 jQuery 吗?
提前致谢。
【问题讨论】:
-
@ChaitanyaGadkari 谢谢。但是有没有可能没有jQuery。比如 id="person + 'person_id'"。
-
看看 [thymeleaf 论坛](forum.thymeleaf.org/…),有一个解决方案使用 th:each 和一个计数器来为输入元素设置 id。
-
@GuillermoFernández。谢谢。我会尝试解决方案。