Reputation: 54
I'm trying in a web application to change the background color with a specific value from the model.
<div class="card" style="width: 18rem; background: [[${task.color}]]" >
</div>
where task.color is a string value of a default html color choosed from the model but this way doesn't work.
How can I change the background color with a color set from the model on the given DIV?
Thanks
Upvotes: 0
Views: 522
Reputation: 20477
If you want Thymeleaf to process attributes, you must prefix them with th:
.
<div class="card" th:style="|width: 18rem; background: ${task.color}|">
</div>
or
<div class="card" style="width: 18rem;" th:styleAppend="|background: ${task.color}|">
</div>
Upvotes: 1