Get previous element text after click

0 votes
asked Jan 12 by Georgy Chernousov

In the following structure

<div class="class name with spaces_9">
 <div class="class name with spaces_8">
  <div class="class name with spaces_7">
    <div class="class name with spaces_6">
     <span class="class name with spaces_5"> price number </span>
   </div>
  </div>
 </div>
</div>
<div class="class name with spaces_3"> some stuff</div>
<div class="class name with spaces_3">
 <form id="123">
  <div class="class name with spaces_2">
   <div class="class name with spaces_1">
    <a id="content" class="button_class">Button text</a>
   </div>  
  </div> 
 </form>
</div>

My purpose is to put string from the span with the class name "class name with spaces_5" into some variable but after user clicks the button in an "a" tag. Such a strange purpose comes from the fact that in actual span on my site i got the price number. There are several blocks with such buttons and prices and all elements have simular class names but different prices. I need to put this code in GTM custom java script variable or custom html tag. Anyway, i need to get value from an apper inside some amount of s after button was clicked.

Please log in or register to answer this question.

...