Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda