1 | < a href = "javascript:void(0);" onclick = "return confirm('ยืนยันการลบข้อมูล')" >ลบรายการนี้</ a > |
ตัวอย่างผลลัพธ์
ลบรายการนี้1 | < a href = "javascript:void(0);" onclick = "return confirm('ยืนยันการลบข้อมูล')" >ลบรายการนี้</ a > |
ตัวอย่างผลลัพธ์
ลบรายการนี้1 | <a href= "ใส่ลิ้งค์ปกติ" onclick= "return confirm('ยืนยันการลบข้อมูล')" >ลบรายการนี้</a> |
1 2 3 4 5 6 | <a href= "javascript:do_something();" onclick= "return confirm('ยืนยันการลบข้อมูล')" >ลบรายการนี้</a> <script> function do_something(){ alert( "OK" ); } </script> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <a href= "#" class = "otherclass confirm-delete" >ลบรายการนี้</a> <script> document.addEventListener( 'DOMContentLoaded' , function () { let linkButton = document.querySelector( ".confirm-delete" ); linkButton.addEventListener( 'click' , function (event) { event.preventDefault(); // Prevent the default action (navigation) alert( 'Link was clicked!' ); if (confirm( 'ยืนยันการลบข้อมูล' )){ do_something(); } }); }); function do_something(){ alert( "OK" ); } </script> |