当前位置:网站首页>How to pass values to onclick events in thymeleaf
How to pass values to onclick events in thymeleaf
2022-06-23 10:03:00 【Roc-xb】
thymeleaf Pass value to onclick event ? Here are two ways .
explain : In the article categories The parameter is one map data structure .
Catalog
Define a js function
<script>
function list_search(cid) {
alert(cid)
}
</script>Method 1 :
<div class="screen_con" id="cat_ids">
<a href="javascript:void(0)" th:onclick="|list_search('')|" class="screen_default red">
There is no limit
</a>
<a href="javascript:void(0)" th:onclick="|list_search('${item.key}')|"
th:each="item:${categories}">
[[${item.value}]]
</a>
</div>Method 2 :
<div class="screen_con" id="cat_ids">
<a data-id="" href="javascript:void(0)" onclick="list_search(this.getAttribute('data-id'))"
class="screen_default red">
There is no limit
</a>
<a th:data-id="${item.key}" href="javascript:void(0)" onclick="list_search(this.getAttribute('data-id'))"
th:each="item:${categories}">
[[${item.value}]]
</a>
</div>边栏推荐
- 什么是BFC?BFC可以解决什么问题
- JSP getting started summary
- RT thread add MSH command
- Form repeated submission problem
- 同花顺推荐么?手机开户安全么?
- A 32KB cache with direct mapping Memory exercises after class
- 开发者,你对云计算可能有些误解
- Gstore weekly gstore source code analysis (IV): black and white list configuration analysis of security mechanism
- Difference between global shutter and roller shutter
- 在OpenCloudOS使用snap安装.NET 6
猜你喜欢

我被提拔了,怎么和原来平级的同事相处?

Comic | code review is driving me crazy!

ThinkPHP 2. X/3.0 vulnerability recurrence

Liujinhai, architect of zhongang Mining: lithium battery opens up a Xintiandi for fluorine chemical industry

太无奈!微软停售 AI 情绪识别等技术,直言:“法律跟不上 AI 的发展”

swagger UI :%E2%80%8B
![[極客大挑戰 2019]HardSQL](/img/73/ebfb410296b8e950c9ac0cf00adc17.png)
[極客大挑戰 2019]HardSQL
![[极客大挑战 2019]HardSQL](/img/73/ebfb410296b8e950c9ac0cf00adc17.png)
[极客大挑战 2019]HardSQL

XML related interview questions

Gorm 高级查询
随机推荐
Go 单元测试
Subscript operator of map
[SUCTF 2019]CheckIn
Go 字符串比较
Alimentation des animaux de compagnie basée sur stm32
Gorm advanced query
CVPR大会现场纪念孙剑博士,最佳学生论文授予同济阿里,李飞飞获黄煦涛纪念奖...
高性能算力中心 — InfiniBand — Overview
谷贱伤农,薪贱伤码农!
高性能算力中心 — RDMA — 实现技术
STM32F1与STM32CubeIDE编程实例-红外寻迹传感器驱动
同花顺推荐么?手机开户安全么?
What is BFC? What problems can BFC solve
[GXYCTF2019]BabySQli
Cesium loading orthophoto scheme
在OpenCloudOS使用snap安装.NET 6
数学分析_笔记_第2章:实数与复数
AI系统前沿动态第38期:谷歌已放弃TensorFlow?;训练大模型的四种GPU并行策略;LLVM之父:模块化设计决定AI前途
Form repeated submission problem
On shore experience of Chang'an University majoring in transportation in 2023