HTML CSS examples for HTML Global Attribute:class
Use the class attribute is in a script.
<!DOCTYPE HTML> <html> <head> <title>Example</title> </head> <body> <a class="class1 class2" href="http://java2s.com">web site</a> <p/> <a class="class2 otherclass" href="http://w3c.org">W3C web site</a> <script type="text/javascript"> var elems = document.getElementsByClassName("otherclass"); for (i = 0; i < elems.length; i++) { var x = elems[i]; x.style.border = "thin solid black"; x.style.backgroundColor = "red"; x.style.color = "black"; } <!-- w ww . j a v a2s. c o m--> </script> </body> </html>