Get id of Button or Clicked Button with jQuery
Get id of Button or Clicked Button with jQuery

html Code
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script src="https://code.jquery.com/jquery-3.6.2.min.js" integrity="sha256-2krYZKh//PcchRtd+H+VyyQoZ/e3EcrkxhM8ycwASPA=" crossorigin="anonymous"></script> <script src="script.js"> </script> </head> <body> <button id = "buttonId"> button Name </button> </body> </html>
Jquery Code
$(document).ready(function(){ $("#buttonId").click(function(){ let id = $(this).attr("id"); alert(id); }); });