+ 3

How do I properly select the datalist for styling?

https://code.sololearn.com/WdB9Z70JD78l/?ref=app

17th Sep 2020, 3:25 AM
Boyan Ivanov
Boyan Ivanov - avatar
5 Answers
17th Sep 2020, 3:38 AM
‎Ashwin Maurya
‎Ashwin Maurya - avatar
+ 3
<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h6>select who is the best?</h6> <!--give a id of select--> <select id="player"> <datalist id="players" class="a"> <option value="neymar">Neymar</option> <option value="messi">Messi</option> <option value="ronaldo">Ronaldo</option> </datalist> </select> <button>Submit</button> <!--put a js--> <script> let dt = document.querySelector("#player") dt.style.color="red" </script> </body> </html>
17th Sep 2020, 3:49 AM
Akash Agrawal
Akash Agrawal - avatar
+ 3
thank you guys, amazing!
17th Sep 2020, 11:41 AM
Boyan Ivanov
Boyan Ivanov - avatar
+ 2
Ashwin Maurya I tried both but it doesn't work
17th Sep 2020, 3:32 AM
Boyan Ivanov
Boyan Ivanov - avatar
+ 1
Boyan Ivanov Give it a class or id as per your need and use that id or class in applying css to it,or can directly use the tags to give them css
17th Sep 2020, 3:31 AM
‎Ashwin Maurya
‎Ashwin Maurya - avatar