W3.JS Agregar estilo a HTML


Agregue un valor de propiedad CSS:

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

Agregar estilo por ID

Agregue un color de fondo rojo a un elemento con id="London":

Ejemplo

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


Agregar estilo por etiqueta

Agregue un color de fondo rojo a todos los elementos <h2>:

Ejemplo

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


Añadir estilo por clase

Agregue un color de fondo rojo a todos los elementos con class="city":

Ejemplo

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