Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

91
Vistas
Javascript - find an element

I'm making an extension and trying to access the element and print it out to the console.log()

<li id="ember7026" class="ember-view c-tab__list__item publicConversation" data-test-id="public-conversation" data-count="1" aria-expanded="false" aria-selected="false"><span class="is_new_flag">NEW</span>Public
</li>

At this point I'm trying to access data-count, however didn't manage to find a way.

I have accessed the whole list by:

var x = document.querySelector("#ember7026")
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can usedataset API to get the test-id.

HTMLElement.dataset

const element =  document.getElementById("ember7026");
const data = element.dataset;

console.log("The ID:", data.testId);
console.log("Count:", data.count);
<li id="ember7026" class="ember-view c-tab__list__item publicConversation" data-test-id="public-conversation" data-count="1" aria-expanded="false" aria-selected="false"><span class="is_new_flag">NEW</span>Public

about 4 years ago · Juan Pablo Isaza Denunciar

0

Original question: "Javascript - find an element"

So it seems like you have already found the element and have a reference to it, and now what you're looking to do is to get a certain attribute from the element reference that you have

To do so simply use the getAttribute function, like

myReferenceToHTMLNode.getAttribute("data-count")

Although I may have misunderstood the question, it's also possible that you're trying to find all elements with a certain attribute (in this case, data attribute) value instead of relying on the individual id.

In that case you can simply do something like

document.querySelector('li[data-count="1"]')

To print a JavaScript value to console, simply call console.log on the Javascript value you want to print, so for example

console.log(ember7026.getAttribute("data-count"))
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda