TypeError:$ items是每个对象上未定义的jquery [英] TypeError: $items is undefined jquery on each

查看:93
本文介绍了TypeError:$ items是每个对象上未定义的jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到此错误:TypeError:$ items未定义

I have this error : TypeError: $items is undefined

var $item = new Array();
var $items = $.each(response, function (i, item) {
    $item[i] = $($($.parseHTML(item)));
    $items.add($item[i]);
});
$grid.append($items);

我不好声明一个变量,您能帮我吗?

I have bad declare a variable, can you help me?

推荐答案

添加var $items = new Array();以便在使用$ items之前将$ items声明为空数组

add var $items = new Array(); to declare $items as an empty array, before using it

var $item = [];
var $items = [];

$items = $.each(response, function (i, item) {
    $item[i] = $($($.parseHTML(item)));
    $items.push($item[i]);
});
$grid.append($items);

这篇关于TypeError:$ items是每个对象上未定义的jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆