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

198
Vistas
How to read specific value from button in js function

I have several buttons contain some values:

<button class="Hotspot" onclick="ChangeView()" slot="hotspot-1" camera.Orbit='2.895deg 85deg 27.92m' ;>

and I need to create function that read camera.Orbit value from button's container after click on it:

function ChangeView() {
    const modelViewer = document.querySelector('#orbit-demo');
    modelViewer.cameraOrbit = camera.Orbit ???
}

I have no idea how to solve this. I do not use getElementbyId because it has to work for all buttons (not specific one). I barely can JS.

Thank you for help.

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

0

You can use Element.getAttribute:

function ChangeView() {
  const modelViewer = document.querySelector('#orbit-demo');
  let orbit = modelViewer.getAttribute('camera.Orbit')
  console.log(orbit)
}
<button class="Hotspot" onclick="ChangeView()" slot="hotspot-1" camera.Orbit='2.895deg 85deg 27.92m' id="orbit-demo">Click</button>

about 4 years ago · Juan Pablo Isaza Denunciar

0

The onclick function passes the click event to the method. You can take the target of this event (the button element) and acquire tha attribute like that.

onclick(e => changeView(e))
ChangeView(e) {
    // do things with e.target.???
}
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