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

332
Views
¿Cómo resolver "TypeError: $(...).length no es una función"?

Mi código es así:

 $(document).ready(function () { size_li = $("#myList li").length(); x=3; $('#myList li:lt('+x+')').show(); $('#loadMore').click(function () { x= (x+5 <= size_li) ? x+5 : size_li; $('#myList li:lt('+x+')').show(); }); $('#showLess').click(function () { x=(x-5<0) ? 3 : x-5; $('#myList li').not(':lt('+x+')').hide(); }); });

O vea la demostración y el código completo aquí: http://jsfiddle.net/oscar11/6FzSb/4177/

yo uso jquery 3.0.1

Cuando se ejecuta, existe un error:

TypeError: $(...).length no es una función

¿Cómo puedo resolverlo?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

En lugar de esto

 $("#myList li").length();

Utilizar este:

 $("#myList li").length;

El $("#myList li") devuelve un objeto similar a una matriz. Todos los objetos tipo matriz tienen una propiedad llamada length , que cuando se lee devuelve el número de elementos contenidos en el objeto tipo matriz. Dicho esto, no hay ninguna función llamada longitud. Por lo tanto length() no tiene sentido.

over 4 years ago · Santiago Trujillo Report

0

length es una propiedad, no una función, así que elimine el ()

 $("#myList li").length;
over 4 years ago · Santiago Trujillo Report

0

length no es una función, es solo Yourthings.length sin (). más doc en documentación extensa

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!