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

125
Views
Encuentre todos los elementos con un cierto valor de atributo en jquery

Necesito encontrar todos los elementos que tengan un valor de atributo especial.

Aquí está el div que necesito encontrar (tengo muchos de ellos ...)

 <div imageId='imageN'>...

Simplemente necesito recorrer los divs que tienen imageId='imageN'

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Aunque no responde con precisión a la pregunta, llegué aquí cuando buscaba una forma de obtener la colección de elementos (nombres de etiquetas potencialmente diferentes) que simplemente tenían un nombre de atributo dado (sin filtrar por valor de atributo). Descubrí que lo siguiente funcionó bien para mí:

 $("*[attr-name]")

Espero que ayude a alguien que llega a esta página buscando lo mismo que yo :).

Actualización: parece que no se requiere el asterisco, es decir, según algunas pruebas básicas, lo siguiente parece ser equivalente a lo anterior (gracias a Matt por señalarlo):

 $("[attr-name]")
over 4 years ago · Santiago Trujillo Report

0

$('div[imageId="imageN"]').each(function() { // `this` is the div });

Para verificar la existencia única del atributo, sin importar el valor, podría usar este selector en su lugar: $('div[imageId]')

over 4 years ago · Santiago Trujillo Report

0

No se llama etiqueta; lo que está buscando se llama un atributo html.

 $('div[imageId="imageN"]').each(function(i,el){ $(el).html('changes'); //do what ever you wish to this object :) });
over 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!