WebDec 25, 2024 · To get the Id of the clicked element in Angular, you can either pass the $event object to the click event handler function, or you can first create a template reference variable and then pass it to the click event handler. Inside the click event handler function, you can easily get the Id of the clicked element by accessing the id attribute of theWebMay 23, 2024 · Yes you can, using getAttribute (), for example : element.getAttribute ('attribute-name'); //return 'attribute-name' attribute NOTE: It's better to pass the object of current clicked element this then get the attribute you want : HTML : Button JS :
jquery - Get ID of the clicked element - Stack Overflow
WebJul 18, 2012 · To get the click ed element you need click event. For example: $ (element).click (function () { var clickedElement = this; }); And to get the focused element you can use :focus selector like: $ (':focus') will returns you focused element in document. Share Follow edited Jan 17, 2024 at 21:53 isherwood 56.6k 16 111 153WebJun 2, 2024 · You can get the id from the click event directly. No need to bind the variable to the event handler. render() { let list = data.map((obj) => { return robins and day croydon reviews
Getting the id of a clicked element from rendered list
WebAug 14, 2024 · Your onClick handler should receive the click event, which should include the id: event.target.id. /* you want to use event.target.id */} className="removeButton">Remove Share Improve this answerWebMay 20, 2015 · To get the id of li on the a click, you need to use closest . This will get the closest li ancestor of the clicked element. $ ('#grade_contamina').on ('click', 'a', function () { alert ($ (this).closest ('li').attr ('id')); return false; }); Share Follow answered May 20, 2015 at 5:47 Tushar 85k 21 157 176 Add a comment 2WebPosting some markup and then asking someone to show you some code is not acceptable here. – gforce301. Mar 9, 2024 at 19:08. add a click event handler onto the elements, …robins and day croydon peugeot