Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
Trying to get the name in Tag Manager

trying to get the element name using jquey, however it is not fetching the name from span tag. i am trying to go into the class id of span, but still can't fetch the name 'Special Offer'.

 jQuery('ul.tools_list > li > a').click(function(){
    var _clickHref = jQuery(this).attr('href');
    var _linkName = jQuery(this).getElement('span.tool_list_text');
    

  
window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
      'event': 'side_menu_click',
      'carouselHref' : _clickHref,
      'menuName' : _linkName
    });
  });  
almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

getElement() is not a jQuery method/function. Use children() or find() instead. Here, I have used the jQuery's text() method to get the content as text. You can also use html() to get the content as HTML.

jQuery('ul > li > a').click(function(){
    var _clickHref = jQuery(this).attr('href');
    var _linkName = jQuery(this).find('span');
   console.log(_linkName.text());
 });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul>
  <li>
    <a href="">
      <span>SpecialOffers</span>
    </a>
  </li>
</ul>

almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!