dom color changing with this
This is a very simple way to achieve some impressive results. The DOM directive is triggered with a simple onClick event, changing the original color of the Click Me! Text to red. You may use a named color, hex color or an RGB color.
The this directive can be very powerful when used in a unique position. However, you wouldn’t want to change many items in a document with this approach. It is inefficient on a large scale and isn’t the best approach to solving the problem of document wide or even selective area alterations.
<html>
<body>
<h1 onclick="this.style.color='red'">Click Me!</h1>
</body>
</html>
You can apply this technique to any properly formed container in any given document, since HTML version 3.2. This functionality is widespread, so it will be included in every version of HTML (and thus DOM) for the foreseeable future.
|