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

136
Vistas
Javascript document.activeElement is undefined on mobile

So currently this function works on desktop but when I test it on mobile I get "undefined." I checked to see if activeElement is compatible on iPhone safari and it says it works there so I'm currently lost. Any fixes or alternatives?

This is the button that is selected.

<input type='button' id='slogan-button' onclick='changeSlogan()' value='Junior Varsity'>

This is the function to make it work.

<script>
    function changeSlogan() {
        const activeSlogan = document.activeElement.value;
      document.getElementById('slogan-input').value = activeSlogan;
      document.getElementById('slogan-display').innerHTML = activeSlogan;
    }
</script>

This is supposed to allow a slogan to be selected and the value of the slogan is added into a input, I get the equal value of the selected slogan only on desktop.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The definition of an ActiveElement is an element which is currently in focus. The elements which are focusable vary by platform with no guarantees. For example, MacOS only considers inputs to be focusable. Based on what you wrote, it seems like iOS is the same.

Use the “click” event instead.

about 4 years ago · Juan Pablo Isaza Denunciar
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