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

141
Vistas
why i cannot execute my alert javascript?

can anyone help me? i've got a silly question. i try to make an alert function using js but it doesnt execute

<script type="text/javascript">
  $(".delete").click(function(){
    alert("Are you sure?");
  });
</script>

and this is my delete button

<td><a class=\"btn delete btn-danger\" href='".base_url().'admin/blog/deleteblog/1'."'>Delete</a></td>
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

It seems to work fine in the example below for me.

<!DOCTYPE html>
<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  </head>
  <body>
    <td><a class="btn delete btn-danger" href="#">Delete</a></td>
  </body>
  <script>
    $(".delete").click(function () {
      alert("Are you sure?");
    });
  </script>
</html>

about 4 years ago · Juan Pablo Isaza Denunciar

0

I'm unsure why you have used the \ around your class name here, but one is within the quotes and one outside. I would remove these.

"btn delete btn-danger"

 <td>
    <a class="btn delete btn-danger" href='".base_url().'admin/blog/deleteblog/1'."'>
       Delete
    </a>
</td>

As for your script, you should check if the document is ready before using JQuery - https://learn.jquery.com/using-jquery-core/document-ready/

<script type="text/javascript">
   $( document ).ready(function() {
        $(".delete").click(function(){
            alert("Are you sure?");
        });
   });
</script>
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