How we get all the attributes of nearest div of current element?
Angular JS, How to get nearest div attributes?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
How we get all the attributes of nearest div of current element?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pasang TamangRank #449 · 5.6K reputationPosted Jan 26, 2023, 12:22 AM EST
Hi Naimish,
Did you try with angular.element()?. With angular.element() you can get the html element and using the closest you can get closest div. Please check below code example.
var divElement = angular.element(document.querySelector('#divId')); var nearestDiv = divElement.closest('div'); var attributes = nearestDiv.prop('attributes'); console.log(attributes);Regards,
Pasang