Java Reference
In-Depth Information
styles for each class in a separate stylesheet; however, there may be times when you have
no access to a stylesheet or its classes.
For example, if you wanted to add a red border around one of the paragraphs (to highlight
it for some reason), you could do it this way:
swim.style.border("red 2px solid");
But a better way would be to add a class of " highlighted ":
swim.classList.add("highlighted");
And then add the following CSS in a separate stylesheet file:
.highlighted{
border: red 2px solid;
}
This would give more flexibility if it was later decided to change the look of the highlighted
elements. It could simply be changed at the CSS level, rather than having to dig around in
the JavaScript code.
Search WWH ::




Custom Search