Created
April 24, 2024 18:06
-
-
Save ziadoz/1feb0ab209527744543ffec9e02ec50c to your computer and use it in GitHub Desktop.
DOM Properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="app"></div> | |
<script> | |
const option = document.createElement('option'); | |
option.value = 'Foo Bar'; | |
const datalist = document.createElement('datalist'); | |
datalist.id = 'foo-bar'; | |
datalist.appendChild(option); | |
const input = document.createElement('input'); | |
input.type = 'text'; | |
input.list = 'foo-bar'; // Doesn't work... | |
input.setAttribute('list', 'foo-bar'); // Does work... | |
const app = document.getElementById('app'); | |
app.appendChild(input); | |
app.appendChild(datalist); | |
</script> | |
<!-- https://jakearchibald.com/2024/attributes-vs-properties/ --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment