我想把onClick上的多个参数从Thymeleaf传递给javascript函数。
<label th:onclick="getUserId(userId,email);" for="radio-11" data-toggle="tooltip" data-placement="bottom" data-trigger="hover" class="pm-tab1-pad">我的Javascript函数是:
<script>
function getUserId(userID,userEmail){
console.log(userID,userEmail);
}
</script>该怎么做呢?
发布于 2019-07-08 20:56:26
可以使用以下命令来完成此操作:
<label th:onclick="getUserId([[${userId}]],[[${email}]] );" for="radio-11" data-toggle="tooltip" data-placement="bottom" data-trigger="hover" class="pm-tab1-pad">这里,userId是整型的,end email是String类型的。
更新:-
这也是可行的:
<label th:data-parameter1="${userId}" th:data-parameter2="${email}" th:onclick="getUserId(this.getAttribute('data-parameter1'),this.getAttribute('data-parameter2'));" for="radio-11" data-toggle="tooltip" data-placement="bottom" data-trigger="hover" class="pm-tab1-pad">https://stackoverflow.com/questions/56935403
复制相似问题