0
How can I use an ID that I defined it in HTML in Javascript?
5 Antworten
+ 2
let element = document.getElementById("YourId");
/* Do something with element */
0
Is it jquery?
0
Soheil Elahi no it is pure JavaScript. You can use var instead of let if you want.
0
Do you know it in CSS?
0
<p id="myID"> </p>
<script>
var myParagraph = document.getElementById("myID");
/* The var myParagraph now has the element you defined in HTML. */
</script>