Variable expression into javascript without using th:inline

前端 未结 6 968
广开言路
广开言路 2020-12-10 04:41

I searched first but I found confusing answers since I\'m new to Thymeleaf and amateurish at best at javascript.

I just want to know how to pass variable expressions

6条回答
  •  鱼传尺愫
    2020-12-10 05:22

    You can not put javascript variables into onclick or other DOM attributes. The value of onclick or any other DOM attribute should be a constant string.

    However, you can dynamically modify value of onclick attribute from javascript, like this:

    yourDomElement.onclick = anyVariable;
    

提交回复
热议问题