Sign in to Community
Sign in to view all badges
I have created an onClick Event Based Rule in Adobe DTM and clicked the “Apply event handler directly to element”.
My CSS Selector is “div.mainTopNav a , a.InfoLinkItem”.
I want to access the clicked anchor tag’s href and text value, but I do not know how to reference the object of the clicked event and it’s corresponding element in the Custom Code Page.
Please could you help me with this?
You would simply use 'this' in custom code to reference the object that was targeted by the rule. So, for example, if you wanted to get the title attribute of the link referenced in your example above, you could use custom code like:
var linkTitle = this.getAttribute("title");
Hope this helps!