我如何使用th:data-url

问题描述 投票:0回答:1

我需要从以下位置获取ID号:

<div class="social"  th:data-url="@{http://localhost:8080/poll?id=${poll.pollId}" data-title="">

但是这不起作用。我该怎么办?

javascript thymeleaf data-uri
1个回答
0
投票

希望这会有所帮助。

//get value of 'this' element that was clicked
var url = $(this).attr('data-url');
// split string and get value of id
var splitted = url.split("id=");

console.log("Id:"+splitted[1]);
© www.soinside.com 2019 - 2024. All rights reserved.