Base: Update radio button test page to mutate the DOM
This commit is contained in:
parent
0069020e6c
commit
2199a59614
Notes:
sideshowbarker
2024-07-18 20:48:54 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/2199a596143 Pull-request: https://github.com/SerenityOS/serenity/pull/6115
1 changed files with 12 additions and 2 deletions
|
@ -30,12 +30,22 @@
|
||||||
<input type=radio id=targaryen name=got value=Targaryen>
|
<input type=radio id=targaryen name=got value=Targaryen>
|
||||||
<label for=targaryen>Targaryen</label>
|
<label for=targaryen>Targaryen</label>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<b>Selected</b>
|
||||||
|
<br />
|
||||||
|
<div style="display: inline-block;">
|
||||||
|
<pre>HP house: <span id=hp></span></pre>
|
||||||
|
<pre>GoT house: <span id=got></span></pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const hp = document.getElementsByName('hp');
|
const hp = document.getElementsByName('hp');
|
||||||
for (let i = 0; i < hp.length; ++i) {
|
for (let i = 0; i < hp.length; ++i) {
|
||||||
hp[i].addEventListener('change', function() {
|
hp[i].addEventListener('change', function() {
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
console.log('HP house:', this.value);
|
document.getElementById('hp').innerHTML = this.value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -44,7 +54,7 @@
|
||||||
for (let i = 0; i < got.length; ++i) {
|
for (let i = 0; i < got.length; ++i) {
|
||||||
got[i].addEventListener('change', function() {
|
got[i].addEventListener('change', function() {
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
console.log('GoT house:', this.value);
|
document.getElementById('got').innerHTML = this.value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue