如何使用javascript获取itemLabel表单JSP的价值?

 <form:radiobutton path="chosenInstitution" id="institution" itemLabel="${institution.name}" itemValue="${institution.id}"></form:radiobutton>

最佳答案

您可以使用getAttribute()方法获取itemValue的值,如下所示:



//getting attribute value
var itemValue = document.getElementById("institution").getAttribute("itemValue");
//printing
console.log("itemValue=" + itemValue);

<form:radiobutton path="chosenInstitution" id="institution" itemLabel="${institution.name}" itemValue="${institution.id}"></form:radiobutton>

09-25 19:18