-3

This is blade.php code

 <a id="delProduct" href="{{ url('/admin/delete-product/'.$product->id) }}" class="btn btn-danger btn-mini">Delete</a> 

This is javascript code

 $("#delProduct").click(function(){
    if(confirm('Are you sure want to delete this Product ?')){
        return true;
    }else{
        return false;
    }
});
baao
  • 71,625
  • 17
  • 143
  • 203
user9697323
  • 201
  • 3
  • 6

1 Answers1

2

You should use classes instead of ID's.
From CSS-Tricks.com:

ID's are unique

  • Each element can have only one ID
  • Each page can have only one element with that ID

Classes are NOT unique

  • You can use the same class on multiple elements.
  • You can use multiple classes on the same element.

Your selector (#delProduct) only targets the first element found with the specified ID, as explained in this answer.

kwyntes
  • 1,045
  • 10
  • 27