title: Looking for custom script (capturing inner HTML using jQuery) in Adobe DTM data element?
body: <p>I am trying to capture HTML text value using jQuery in custom script of DTM data element. </p>
  
  <p>See the scenario:</p>
  
  <p>Below is the snippet of code on the page: </p>
  
  <pre><code>&lt;div class="site-categories"&gt;
  &lt;ul&gt;
     &lt;li class="mobile-tablets main"&gt;
      &lt;a href="/mobiles.html" class="mobile-tablets" style="background-position"&gt; Mobiles &amp; Tablets &lt;/a&gt; 
      &lt;a href="/computers.html" class="computers" style="background-position"&gt; Computers &lt;/a&gt; 
      &lt;a href="/electronics.html" class="electronics" style="background-position"&gt; Electronics &lt;/a&gt; 
  </code></pre>
  
  <p>and so on.</p>
  
  <p>So basically the ask is to capture the inner HTML text of anchor tag i.e. 'Mobiles &amp; Tablets' or 'Computers' or 'Electronics', depending upon on what link, user clicks.</p>
  
  <p>To achieve this, in the event based rule section, I have set Condition as the tag to fire when class (under div tag) equals 'site-categories' and enabled bubbling on child elements (so as to cover everything under this to fire omniture tag). And then assigning the value of data element in any evar variable.</p>
  
  <p>In the data element section, after selecting the custom script option, I am writing this code:</p>
  
  <pre><code>var value = $('this').html();
  </code></pre>
  
  <p>return value;</p>
  
  <p>or </p>
  
  <pre><code>var value = jQuery('this').html();
  </code></pre>
  
  <p>return value;</p>
  
  <p>But this is not working. I even tried using this:</p>
  
  <p>var value;</p>
  
  <pre><code>_satellite.setVar('value', jQuery('this').html()); 
  </code></pre>
  
  <p>return value;</p>
  
  <p>But this also didn't worked. Can I have a solution for this ? I want this to be dynamic as in, depending upon which section user is clicking on the page, the data element should capture the inner HTML text of that particular anchor tag.</p>
  
  <p>Not sure where I am going wrong.
  If there is any other solution that exist for this, please let me know. That would be a great help.</p>
  
  <p>Thanks in advance,</p>
  
  <p>Adi</p>