W3.JS Voeg styl by HTML


Voeg 'n CSS-eienskapwaarde by:

w3.addStyle(selector,'property','value')

Voeg styl by id

Voeg 'n rooi agtergrondkleur by 'n element met id="London":

Voorbeeld

<button onclick="w3.addStyle('#London','background-color','red')">Add Style</button>


Voeg styl by tag

Voeg 'n rooi agtergrondkleur by alle <h2>-elemente:

Voorbeeld

<button onclick="w3.addStyle('h2','background-color','red')">Add Style</button>


Voeg styl volgens klas by

Voeg 'n rooi agtergrondkleur by alle elemente met class="city":

Voorbeeld

<button onclick="w3.addStyle('.city','background-color','red')">Add Style</button>