0

What does attribute "class" do

5th Dec 2019, 1:48 AM
TONICswift
TONICswift - avatar
2 odpowiedzi
+ 1
The class attribute is a way for CSS and JavaScript to access multiple elements at once. For example, with CSS: The HTML: <div class='bordered'> ... </div> <img class="bordered"...></img> The CSS: .bordered { border: 1px black solid; } That will give both the div and the image a border. The class attribute is also sometimes important to JavaScript. var borderedElements = document.getElementsByClassName("bordered"); for each (elem in borderedElements) { elem.remove(); } That would remove all the elements with class="bordered" from the DOM.
5th Dec 2019, 2:30 AM
Erik Johanson
Erik Johanson - avatar
0
Thnk you
5th Dec 2019, 2:37 AM
TONICswift
TONICswift - avatar