0

How can I use an ID that I defined it in HTML in Javascript?

19th Sep 2018, 3:16 PM
Fathjf
5 odpowiedzi
+ 2
let element = document.getElementById("YourId"); /* Do something with element */
19th Sep 2018, 3:22 PM
N00B
0
Is it jquery?
19th Sep 2018, 3:27 PM
Fathjf
0
Soheil Elahi no it is pure JavaScript. You can use var instead of let if you want.
19th Sep 2018, 3:30 PM
N00B
0
Do you know it in CSS?
19th Sep 2018, 3:30 PM
Fathjf
0
<p id="myID"> </p> <script> var myParagraph = document.getElementById("myID"); /* The var myParagraph now has the element you defined in HTML. */ </script>
26th Sep 2018, 11:39 AM
Gorbachov Ozuna
Gorbachov Ozuna - avatar