Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

281
Visualizações
How to make inner elements of a container not able to be clickable and selected

I want to implement a loading state where when we click on the button, we make the container opacity to .32 and we shouldn't be able to click or select the elements inside the container. In the example below, the inner a tag is still clickable and selectable after the loading is shown.

const container = document.getElementById('container');
const btn = document.getElementById('load');

btn.addEventListener('click', () => {
    container.classList.add('loading');
})
#container {
  width: 300px;
  height: 300px;
  background: tomato;
}

.loading {
  opacity: .32;
  user-select: none;
}
<div id="container">
    <a href="www.google.com">Test</a>
    <a href="www.google.com">Test</a>
    <a href="www.google.com">Test</a>
    <a href="www.google.com">Test</a>
</div>

<button id="load">
  Load
</button>

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Have you looked into using pointer-events: none; from CSS? See running snippet below.

const container = document.getElementById('container');
const btn = document.getElementById('load');

btn.addEventListener('click', () => {
    container.classList.add('loading');
})
#container {
  width: 300px;
  height: 300px;
  background: tomato;
}

.loading {
  opacity: .32;
  user-select: none;
  pointer-events: none;
}
<div id="container">
    <a href="www.google.com">Test</a>
    <a href="www.google.com">Test</a>
    <a href="www.google.com">Test</a>
    <a href="www.google.com">Test</a>
</div>

<button id="load">
  Load
</button>

about 4 years ago · Juan Pablo Isaza Relatório

0

I believe what you are trying to do is, disabling the anchor tag. For this, you can simply use the following property in the CSS: pointer-events: none;.

With this even if the anchor tag is clicked, nothing will happen.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda