Difference between revisions of "DOM Common Logic"
Jump to navigation
Jump to search
Line 18: | Line 18: | ||
document.body.append('Weeee...'); | document.body.append('Weeee...'); | ||
} | } | ||
</pre> | |||
<pre class=ans> | |||
document.body.innerHTML = ` | |||
<label>I am over 1.2m | |||
<input type=checkbox id=tall> | |||
</label> | |||
<button id=ride disabled>Ride the rollercoaster</button> | |||
`; | |||
document.getElementById('ride').onclick = ()=>{ | |||
document.body.append('Weeee...'); | |||
} | |||
document.getElementById('tall').onclick = ()=>{ | |||
document.getElementById('ride').removeAttribute('disabled') | |||
} | |||
</pre> | |||
</div> | |||
==Age verification== | |||
<div class=qu data-width=300> | |||
You must be 18 to see the smutty image. | |||
<pre class=usr> | |||
document.body.innerHTML = ` | |||
<label>I am over 18 | |||
<input type=checkbox id=adult> | |||
</label> | |||
<a id=link disabled href=https://www.imdb.com/title/tt0058331/mediaviewer/rm3665206785/>smutty</a> | |||
`; | |||
</pre> | </pre> | ||
Revision as of 15:03, 3 October 2021
A checkbox to enable a button
You must be 1.2m to to ride
- Add this code to allow the user to enable the button.
document.getElementById('tall').onclick = ()=>{ document.getElementById('ride').removeAttribute('disabled') }
document.body.innerHTML = ` <label>I am over 1.2m <input type=checkbox id=tall> </label> <button id=ride disabled>Ride the rollercoaster</button> `; document.getElementById('ride').onclick = ()=>{ document.body.append('Weeee...'); }
document.body.innerHTML = ` <label>I am over 1.2m <input type=checkbox id=tall> </label> <button id=ride disabled>Ride the rollercoaster</button> `; document.getElementById('ride').onclick = ()=>{ document.body.append('Weeee...'); } document.getElementById('tall').onclick = ()=>{ document.getElementById('ride').removeAttribute('disabled') }
Age verification
You must be 18 to see the smutty image.
document.body.innerHTML = ` <label>I am over 18 <input type=checkbox id=adult> </label> <a id=link disabled href=https://www.imdb.com/title/tt0058331/mediaviewer/rm3665206785/>smutty</a> `;
document.body.innerHTML = ` <label>I am over 1.2m <input type=checkbox id=tall> </label> <button id=ride disabled>Ride the rollercoaster</button> `; document.getElementById('ride').onclick = ()=>{ document.body.append('Weeee...'); } document.getElementById('tall').onclick = ()=>{ document.getElementById('ride').removeAttribute('disabled') }