Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

385
Vistas
.innerHTML JS not working on <a> element?

I am trying to implement custom button styles on my website from https://cssbuttons.io/detail/cssbuttons-io/brown-otter-21.

The "button" is contained in this HTML on the website:

<div class="et_pb_button_module_wrapper et_pb_button_3_wrapper  et_pb_module ">
                <a id="fancy" class="et_pb_button et_pb_button_3 fancy et_pb_bg_layout_light" href="">VIEW MORE</a>
            </div>

I have added the CSS from the button styles in the link above, as well as this JS to try to implement the HTML set up they have:

document.addEventListener("DOMContentLoaded", function(event) { 
    var button = document.getElementsByClassName('fancy');
    var buttonText = button.innerHTML;
    button.innerHTML = `
<span class="top-key"></span>
<span class="text">${buttonText}</span>
<span class="bottom-key-1"></span>
<span class="bottom-key-2"></span>
`;
    console.log("Button JS Loaded.");
});

The a element is not getting changed, and the message does not load in console on the website.

I have put all the code into JSFiddle here: https://jsfiddle.net/aliyaconrad/oc273g4u/4/

Any insight as to why this code might not be working would be much appreciated!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda