Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
Onclick no llama a la función en php echo for loop

Creé un bucle de div como miniaturas de imágenes en las que se puede hacer clic y cada div obtiene un método onclick mientras que el bucle for pero si hago clic en las miniaturas, no llama a mi función test().

No se donde esta el fallo.

Estaría muy feliz por cada ayuda.

hay alguna solución para hacer esto?

estoy sentado desde horas en ese problema pero sin éxito.

¡Muchas gracias por las ayudas!

 <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css"> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js"></script> </head> <style> .album-container { display: flex; flex-wrap: wrap; background-color: white; } .album-container > div { background-size: cover; background-position: center; background-repeat: no-repeat; width: 115px; height: 115px; margin: 10px; cursor: pointer; border:1px solid lightgray; } .album-container > div:hover{ opacity: 0.7; transition-duration: 0.5s; width: 120px; height: 120px; } </style> <script> function test(){ alert("HELLO"); } </script> <body> <div class="container album-container"> <?php $path = 'pics/gallery'; $files = scandir($path); $files = array_diff(scandir($path), array('.', '..')); foreach($files as $file){ echo '<div class="photo_thumb" id="'.$file.'" onclick="test()" style="background-image:url(pics/gallery/'.$file.')"></div>'; } ?> </div> </body>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!