<!DOCTYPE html>
<
html
>
<
body
>
<
h1
style
=
"color:green;font-size:39px;"
>
GeeksForGeeks
</
h1
>
<
h2
>DOM Datalist object</
h2
>
<
form
id
=
"GFG"
>
<
b
><
label
>Your cars name:</
label
></
b
>
</
form
>
<
br
>
<
button
onclick
=
"myGeeks()"
>Submit</
button
>
<
script
>
function myGeeks() {
let g = document.createElement("INPUT");
g.setAttribute("list", "cars");
document.getElementById("GFG").appendChild(g);
let f = document.createElement("DATALIST");
f.setAttribute("id", "cars");
document.getElementById("GFG").appendChild(f);
let w = document.createElement("OPTION");
w.setAttribute("value", "BMW");
document.getElementById("cars").appendChild(w);
let x = document.createElement("OPTION");
x.setAttribute("value", "Mercedes");
document.getElementById("cars").appendChild(x);
}
</
script
>
</
body
>
</
html
>