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

219
Views
jQuery coincide solo con una parte de la identificación de div

Me encontré con una situación inusual ayer por la noche.

Necesito hacer coincidir solo una parte de la identificación. Déjame aclararte todo con un ejemplo.

Tengo pocos divs como

 <div id="sales_info_1">... ...... ...... ...... ...</div> <div id="sales_info_2">... ...... ...... ...... ...</div> <div id="sales_info_3">... ...... ...... ...... ...</div>

y jQuery va como

 jQuery("div#dont_know_what_to_write_here").bind("click", function(){ ... ...... ...... ...... ... });

Necesito hacer coincidir solo sales_info , ignorando _1, _2 o _anything, ¿alguien puede sugerirme cómo lograr esto?

Gracias

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Puede usar el selector "Comienza con" :

 $('div[id^="sales_info_"]')

Sin embargo, prefiero recomendarle que use un nombre de clase único para sus elementos que pueda seleccionar.

over 4 years ago · Santiago Trujillo Report

0

Alternativamente, agregue class="sales_info" a su marcado HTML.

Entonces, haz esto:

 $(".sales_info").bind("click", function() { ... }
over 4 years ago · Santiago Trujillo Report

0

Desea que el atributo comience con selector :

 $('div[id^="sales_info"]').bind( ... );
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!