human thymeleaf给onclick赋值;
Thymeleaf给onclick赋值的语法如下:
<button th:onclick="'javascript:myFunction(\'' + ${variableName} + '\');'">Click me</button>
其中,${variableName}是Thymeleaf中的变量名,可以替换为具体的变量值。myFunction是JavaScript函数的名称。在onclick中,我们使用单引号将整个JavaScript代码包含起来,并使用双引号将变量值括起来。
原文地址: https://www.cveoy.top/t/topic/cNW6 著作权归作者所有。请勿转载和采集!