Expand my Community achievements bar.

Set a rule for click event - but the page elements are ALL the same, except the text (help)

Avatar

Level 2

stomped. Hoping someone can help me out here. I have to set up a rule that triggers a click event when a user selects "Buy Now." I was looking at the pages and noticed that the buttons are set up the same way across the pages, and the only difference is the text.

 

I had started the below but that's when I noticed that it wouldn't work since other buttons are using the same setup.

 

This is the HTML:

<button _ngcontent-qol-c212="" preventmultipleclicks="" class="btn btn-transition sm-text-centered btn-block margin-top-20 btn-primary ng-star-inserted" id="myEngine.footerButton.next" data-e2e="transition-button-next">Buy now</button>

 

SofiDel_1984_0-1719867128312.png

 

any advice?

 

maybe create a data element like

 

var buyOncomplete = document.getElementsByClassName("btn btn-transition sm-text-centered btn-block margin-top-20 btn-primary ng-star-inserted")[0].innerText;
return buyOncomplete;

 

then add it to the rule as a condition - could that work?

 

1 Reply

Avatar

Level 4

Hi @SofiDel_1984 

You can try using this keyword by adding a condition in your rule to check for the text "Buy now"

$(this).text == "Buy now"
return true;