Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/431.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从div中的图像创建数组_Javascript_Jquery_Arrays - Fatal编程技术网

Javascript 如何从div中的图像创建数组

Javascript 如何从div中的图像创建数组,javascript,jquery,arrays,Javascript,Jquery,Arrays,错误:未捕获的语法错误:意外标识符使用: 。。。或者像这样修改原始代码: var arr = $("#w01 > img").toArray(); var arr=[]; $(“#w01>img”)。每个(函数(){ arr.push(this);//this而不是$(this),因此您只获得 }); // 你错过了一个最后的机会 警报(arr); 你忘了放“')” 在这里: $(“#w01>img”)。每个(函数(){ arr.push($(此)); }); // var arr =

错误:
未捕获的语法错误:意外标识符

使用:

。。。或者像这样修改原始代码:

var arr = $("#w01 > img").toArray();
var arr=[];
$(“#w01>img”)。每个(函数(){
arr.push(this);//this而不是$(this),因此您只获得
}); // 你错过了一个最后的机会
警报(arr);
你忘了放“')”

在这里:

$(“#w01>img”)。每个(函数(){
arr.push($(此));
}); //
var arr = [];
$("#w01 > img").each(function(){
    arr.push($(this));
}
alert (arr) //error
var arr = $("#w01 > img").toArray();
var arr = [];
$("#w01 > img").each(function(){
    arr.push(this); // this instead of $(this) so you only get the <img>
}); // you were missing a closing paren
alert(arr);
$("#w01 > img").each(function(){
    arr.push($(this));
}); //<<<<