refactor: refine examples
This commit is contained in:
parent
5015fe1d0c
commit
ac5f74edc2
@ -1,8 +0,0 @@
|
||||
|
||||
function greetWorld() {
|
||||
alert("hello world")
|
||||
}
|
||||
|
||||
function salute(name) {
|
||||
alert("hello: " + name)
|
||||
}
|
@ -4,9 +4,16 @@
|
||||
<meta charset="UTF-8" />
|
||||
<title>Thymeleaf: Javascript function call</title>
|
||||
</head>
|
||||
<script type="text/javascript"
|
||||
src="../js/functionCall.js">
|
||||
<script th:inline="javascript">
|
||||
function greetWorld() {
|
||||
alert("hello world")
|
||||
}
|
||||
|
||||
function salute(name) {
|
||||
alert("hello: " + name)
|
||||
}
|
||||
</script>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<div> Thymeleaf: Javascript function call </div>
|
||||
@ -14,11 +21,10 @@
|
||||
<main>
|
||||
<section class="flex-box">
|
||||
<button th:onclick="greetWorld()">using no variable</button>
|
||||
<button th:onclick="'alert(\' 1. static variable used here.\');'">using static variable</button>
|
||||
<button th:onclick="'alert(\' '1. There are exactly + ${totalStudents} + students'\');'">using inline dynamic variable</button>
|
||||
<button th:onclick="'javascript:alert(\''2. There are exactly + ${totalStudents} + students'\');'">using javascript:function</button>
|
||||
<button th:onclick="'alert(\'static variable used here.\');'">using static variable</button>
|
||||
<button th:onclick="'alert(\'There are exactly ' + ${totalStudents} + ' students\');'">using inline dynamic variable</button>
|
||||
<button th:onclick="'javascript:alert(\'There are exactly ' + ${totalStudents} + ' students\');'">using javascript:function</button>
|
||||
<button th:data-name="${student.name}" th:onclick="salute(this.getAttribute('data-name'))">using data attribute</button>
|
||||
<button th:onclick="@{'salute(' + ${student.name} + ');'}">using @ tag</button>
|
||||
<button th:onclick="salute([[${student.name}]])">using double brackets</button>
|
||||
</section>
|
||||
</main>
|
||||
|
Loading…
x
Reference in New Issue
Block a user