0
id and class
Are the use of id and class attributes in tags purposely for styling in CSS or do they have other uses?
1 Antwort
+ 2
They most certainly do. While they are the core of CSS - CSS3 programming, they are a large part of JavaScript as well.
For example, say you have a cipher software that reverses a phrase. Without IDs, you would have to use pure prompt()'s!
<body>
<input type="text" id="normalText">
<script>
var text= document.getElementById("normalText").innerHTML;
switch(text){
case "a":
//some code;
break;}
</script>
</body>
If you didn't have the ID, you couldn't change the text! See?