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

249
Visualizações
¿Cómo puedo agregar una descripción para mostrar cuando se hace clic en una imagen?

Cuando hago clic en una imagen, se abre en un cuadro de imagen más grande. Quiero agregar una descripción a cada imagen que se abre debajo del cuadro de imagen cuando abro esa imagen en particular. Como se muestra en la imagen, quiero mostrar la descripción de esa imagen en particular debajo del cuadro de imagen más grande cuando se hace clic en la imagen.

 $(document).ready(function() { $(".Thumbnail a").click(function(e) { e.preventDefault(); $(".imgBox img ").attr("src", $(this).attr("href")); }); }); document.addEventListener("mousemove", showImage); document.addEventListener("mouseleave", showImage); document.addEventListener("scroll", showImage); function showImage() { var items = document.getElementById("thumbnail").getElementsByTagName("li"); Array.from(items).forEach(function(e) { if (e.getElementsByTagName("img")[0].matches(":hover")) { //put whatever you want in here e.style.backgroundColor = "blue"; } else { //likewise put whatever you want in here e.style.backgroundColor = "red"; } }); }
 <body> <div class="imgBox"><img src="" alt="" /></div> <ul class="Thumbnail" id="thumbnail"> <li> <a href="img1.jpg" target="imgBox"><img src="img1.jpg" width="120px" /></a> </li> <li> <a href="img2.jpg" target="imgBox"><img src="img2.jpg" width="120px" /></a> </li> <li> <a href="img3.jpg" target="imgBox"><img src="img3.jpg" width="120px" /></a> </li> <li> <a href="img4.jpg" target="imgBox"><img src="img4.jpg" width="120px" /></a> </li> <li> <a href="img5.jpg" target="imgBox"><img src="img5.jpg" width="120px" /></a> </li> </ul> </body> <script src="https://code.jquery.com/jquery-2.2.4.js"></script>

ingrese la descripción de la imagen aquí

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

0

Me inclinaría a usar la figure para esto, ya que hace un envoltorio ordenado tanto para una imagen como para un pie de foto.

 // Cache a container, and add a listener to it const container = document.querySelector('div'); container.addEventListener('click', handleClick, false); function handleClick(e) { // If the clicked element is an image if (e.target.matches('img')) { // Get its parentNode (figure) const parent = e.target.parentNode; // Get the `figcaption` const caption = parent.querySelector('figcaption'); // Toggle its `showcaption` class caption.classList.toggle('showcaption'); } }
 figure { display: inline-block; } figure img:hover { cursor: pointer; } figcaption { visibility: hidden; } .showcaption { visibility: visible; }
 <div> <figure> <img src="https://dummyimage.com/100x100/000/fff" alt="Dummy image"> <figcaption>Dummy image</figcaption> </figure> <figure> <img src="https://dummyimage.com/100x100/f44/000" alt="Dummy image 2"> <figcaption>Dummy image 2</figcaption> </figure> </div>

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