Reputation: 5271
I have a function where I want the speed of the slideToggle to be dependent on how many children/list items are in the list "$(this).prevAll('.list_category:first')
". Can someone tell me where I'm being stupid?
$(".expand").click(function() {
var iNum = $(this).prevAll('.list_category:first').length();
var tNum = iNum*100;
$(this).prevAll('.list_category:first').slideToggle(tNum, function(){
Upvotes: 1
Views: 336
Reputation: 63435
Remove the parentheses from length()
:
var iNum = $(this).prevAll('.list_category:first').length;
Or you can use .size()
var iNum = $(this).prevAll('.list_category:first').size();
Upvotes: 2