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" />
|
<meta charset="UTF-8" />
|
||||||
<title>Thymeleaf: Javascript function call</title>
|
<title>Thymeleaf: Javascript function call</title>
|
||||||
</head>
|
</head>
|
||||||
<script type="text/javascript"
|
<script th:inline="javascript">
|
||||||
src="../js/functionCall.js">
|
function greetWorld() {
|
||||||
|
alert("hello world")
|
||||||
|
}
|
||||||
|
|
||||||
|
function salute(name) {
|
||||||
|
alert("hello: " + name)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<div> Thymeleaf: Javascript function call </div>
|
<div> Thymeleaf: Javascript function call </div>
|
||||||
@ -14,11 +21,10 @@
|
|||||||
<main>
|
<main>
|
||||||
<section class="flex-box">
|
<section class="flex-box">
|
||||||
<button th:onclick="greetWorld()">using no variable</button>
|
<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(\'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="'alert(\'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="'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: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>
|
<button th:onclick="salute([[${student.name}]])">using double brackets</button>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user