Reputation:
I have list of data coming from the database and my logic in jQuery is not working, I have 100 as total number of data. So what I want is if the list is less than 99 hide something else if the list is more than 100 then show something, this is what I placed under ajax success handler. I have tried loading 28 data and 100 but both time it hides 'something'. Can someone suggest why?
success: function(data){
if (data < 99) {
$('#something').show();
} else {
$('#something').hide();
} }
When I first loaded my data was it was equal to 28 and the second time it was 129 and both the time brake point moved into hide();
Upvotes: 0
Views: 91
Reputation: 152226
If data
is an array object, you should try with:
if (data.length < 99)
Also you can simplify your syntax:
$('#something').toggle(data.length < 99);
Upvotes: 10