Expand my Community achievements bar.

SOLVED

DTM Rule based Event Handler

Avatar

Level 1

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?

1 Accepted Solution

Avatar

Correct answer by
Level 3

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!

-Shawn

View solution in original post

1 Reply

Avatar

Correct answer by
Level 3

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!

-Shawn