【发布时间】:2021-08-08 15:04:47
【问题描述】:
我想使用 HTML 选择元素来更改显示的百里香片段。
html代码:
<label for="algorithm">Algorithm</label>
<select id="algorithm" onchange="getAlgorithmParams(this.value, '#algParams')">
<option value="">Select Algorithm</option>
<option value="ZeroR">ZeroR</option>
<option value="OneR">OneR</option>
<option value="NaiveBayes">Naive Bayes</option>
<option value="IBK">IBK</option>
<option value="J48">J48</option>
</select>
<div id="algParams"></div>
javascript代码:
getAlgorithmParams = function (algorithmName, elementID){
console.log(algorithmName);
console.log(elementID);
document.querySelector(elementID).innerHTML = "<div th:insert='~{/fragments/parameter-fragments :: " + algorithmName + "}'></div>";
}
when the selection is changed i want the div element with the id "algParams" to display a different thymeleaf fragment.当我运行它时,它会在我检查页面时显示在页面元素中。
<div th:insert="~{/fragments/parameter-fragments :: OneR}"></div>
这是正确的表示法,应该可以工作。
【问题讨论】:
标签: javascript html spring-boot thymeleaf