-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
  • 67,185
  • 15
  • 124
  • 181
user9697323
  • 71
  • 2
  • 5

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
  • 822
  • 8
  • 20