Capturing sibling text of the clicked element through launch | Community
Skip to main content
Saravanan_Dharmaraj
New Participant
October 5, 2022
Solved

Capturing sibling text of the clicked element through launch

  • October 5, 2022
  • 2 replies
  • 1287 views

We have a rule in Launch to capture a paragraph(".link.sl-cta.video") click in the DOM. We also want to capture the text present in sibling div when the paragraph is clicked. We tried the below custom code in the data element to get the sibling value. nothing works. Any help appreciated. Thanks


var text = $(this).parent().find(".content-block-heading").text();

console.log(text);
var text1 = $(this).siblings(".content-block-heading").text();

console.log(text1);

 

The rule is getting trigger when the link click happens

 

 

 

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Saravanan_Dharmaraj

Thanks for the reply. Plain javascript code didnt work.

 

Below one worked.

$(event.target).parent().find(".content-block-heading").text()

2 replies

tim_funk
New Participant
October 5, 2022

It looks like jQuery is missing. But you can do this via regular javascript 

 

this.parentElement.querySelector(".content-block-heading").innerText
Saravanan_Dharmaraj
Saravanan_DharmarajAuthorAccepted solution
New Participant
October 5, 2022

Thanks for the reply. Plain javascript code didnt work.

 

Below one worked.

$(event.target).parent().find(".content-block-heading").text()

Saravanan_Dharmaraj
New Participant
October 5, 2022

i also read https://jimalytics.com/tag-management/adobe-launch-data-elements-guide/#Custom_Code 

$(this) - wont work in launch, so we have to use the utilities.. Could anyone point me to the doc where the utilities are mentioned? Thanks