• Jobs
  • About Us
  • Jobs
    • Home
    • Jobs
    • Courses and challenges
  • Businesses
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Hire tech talent
    • Blog
    • Sales
    • Salary Calculator

0

391
Views
jQuery: ¿cómo comprobar si existe un elemento?

Sé que puede probar el width() o el height() pero ¿qué pasa si la propiedad de visualización del elemento está configurada en ninguno? ¿Qué otro valor hay que comprobar para asegurarse de que el elemento existe?

almost 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Puede usar la longitud para ver si su selector coincidió con algo.

 if ($('#MyId').length) { // do your stuff }
almost 4 years ago · Santiago Trujillo Report

0

Suponiendo que está tratando de encontrar si existe un div

 $('div').length ? alert('div found') : alert('Div not found')

Consulte el ejemplo de trabajo en http://jsfiddle.net/Qr86J/1/

almost 4 years ago · Santiago Trujillo Report

0

Puedes usar el selector visible:

http://api.jquery.com/selector-visible/

almost 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!