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

139
Views
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 answers
Answer question

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 Report

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