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

314
Views
How to solve "TypeError: $(...).length is not a function"?

My code is like this :

$(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();
    });
});

Or see demo and full code here : http://jsfiddle.net/oscar11/6FzSb/4177/

I use jquery 3.0.1

When executed, there exist error :

TypeError: $(...).length is not a function

How can I solve it?

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Instead of this

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

Use this:

$("#myList li").length;

The $("#myList li") returns an array like object. All array like objects have a property called length, which when be read returns the number of items contained in the array like object. That being said there isn't any function called length. Hence length() is meaningless.

about 4 years ago · Santiago Trujillo Report

0

length is a property, not a function, so remove the ()

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

0

length is not a function it is just Yourthings.length without (). more doc at length documentation

about 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!