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

140
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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