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

167
Vistas
Javascipt to hide by class and the name

I want to hide by the class and the name attribute in div

This wont work

$("div.ind_post").find("[name^='1']").hide();

This work

$("div.ind_post").hide();
$("div").find("[name^='1']").hide();

I wonder why i can hide by the element with class, or the name, but i cannot hide with class and name both. so my question is how to hide within the class, by a specify name, thanks!

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

find searches descendants

Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.

You should do

$("div.ind_post[name^='1']").hide();

I suspect the reason why $("div").find("[name^='1']").hide(); worked is that you had some div element higher up in the DOM hierarchy

about 4 years ago · Juan Pablo Isaza Denunciar

0

Keeping in mind that name attributes are not allowed on div elements.

find searches the descendants of the selected elements.

If you want an element which matches a class selector and an attribute selector then you need to either search for them together in the first place:

 $("div.ind_post[name^='1']")

or filter the collection of matched elements on the extra rule

 $("div.ind_post").filter("[name^='1']").hide();
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