[英]If statment is not working in jquery
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. 我有来自数据库的数据列表,而我在jQuery中的逻辑不起作用,我的数据总数为100。 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.
所以我想要的是,如果列表少于99,则隐藏其他内容;如果列表大于100,则显示其他内容,这就是我放在ajax成功处理程序下的内容。 I have tried loading 28 data and 100 but both time it hides 'something'.
我曾尝试加载28个数据和100个数据,但两次都隐藏了“某物”。 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(); 当我第一次加载数据时,它等于28,第二次是129,两个制动点都移到了hide()中。
If data
is an array object, you should try with: 如果
data
是数组对象,则应尝试:
if (data.length < 99)
Also you can simplify your syntax: 您还可以简化语法:
$('#something').toggle(data.length < 99);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.