I verified and fixed it.
index.html
<select id=“select_mult”>
<option th:each="user : ${user_list}" th:value="${user.id} + ',' + ${user.name}">[[${user.name}]]
</select>
<span id="user_name"></span>
script.js
$(function(){
$('#select_mult').change(function(){
var str = $('#select_mult option:selected').val().split(',');
var id = str[0];
var name = str[1];
$('#user_name').val(id);
$('#user_name').text(name);
});
});
Recommended Posts