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

166
Vistas
How to show a button after one of the two buttons are clicked?

I want two buttons to appear right after one of the two buttons prior is pressed.

var a = "Jeg heter ";
var b = "Benjamin";
var j = "Jasmin";

function endre() {
  var x = document.getElementById("endre1");
  if (x.innerHTML == "Velg navn" || j) {
      x.innerHTML = a + b;
  }
}

function endre2() {
  var x = document.getElementById("endre1");
  if (x.innerHTML == "Velg navn" || b) {
      x.innerHTML = a + j;
   }
}
<button onclick="endre2()">Jasmin</button>
<button onclick="endre()">Benjamin</button>
<div id="endre1">Velg navn</div>
<br>
<button class="visknapp24()" style="display: none;">24 år</button>
<button class="visknapp20()" style="display: none;">20 år</button>

Any way to add to this?

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

0

Firstly you need the same function to show for both the buttons. Also, you have to just query the buttons using either querySelector() or getElementsByClassName().

Once you have that you can use style property from JS to modify CSS styles:

var a = "Jeg heter ";
    var b = "Benjamin";
    var j = "Jasmin";

    function endre() {
    var x = document.querySelector(".visknapp24");
    var y = document.querySelector(".visknapp20");
   x.style.display = 'block';
   y.style.display = 'block';
   
}
<button onclick="endre()">Jasmin</button>
<button onclick="endre()">Benjamin</button>
<div id="endre1">Velg navn</div>
<br>
<button class="visknapp24" style="display: none;">24 år</button>
<button class="visknapp20" style="display: none;">20 år</button>

about 4 years ago · Juan Pablo Isaza Denunciar

0

You would add an id to your buttons, then update the style.

<button id='btn1' class="visknapp20()" style="display: none;">20 år</button>
function endre() {
  var x = document.getElementById("endre1");
  if (x.innerHTML == "Velg navn" || j) {
      x.innerHTML = a + b;
      document.getElementById("btn1").style.display='inline'
  }
}

It might be better to use the visibility style verses the display style.

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