好的,所以我正在使用SpringBoot开发一个Web项目,并使用Thymeleaf作为模板引擎,在一个页面中我有以下内容:
[...]<span th:switch="${cost.achitat}" class="pull-right">
<span th:case='true' class="btn btn-xs btn-default" >
<span class="glyphicon glyphicon-remove" aria-hidden="true" th:value="${cost.cost_id}"></span>
</span>
<span th:case='false' class="btn btn-xs btn-default">
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
</span>
</span>[...]
(对象的“achitat”参数是布尔值,我有一个th:每个th:在一个更高的分区中,如果我用th:文本设置文本,它会在我的页面上正确显示,因此值正在被传输)
真
jquery案例:
$(document).ready(function(){
$('.glyphicon.glyphicon-remove').click(function(){
var t = $(this).val();
alert(t);
});});
但警报总是空的。我知道这个问题以前有人以某种形式提出过,但我找不到解决办法,我不知道我做错了什么。
谢谢!