Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.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/9/visual-studio/7.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
Jquery 在“新建”选项卡中打开阵列中的每个链接_Jquery_Tabs - Fatal编程技术网

Jquery 在“新建”选项卡中打开阵列中的每个链接

Jquery 在“新建”选项卡中打开阵列中的每个链接,jquery,tabs,Jquery,Tabs,我有一个类似的数组 myArray=[“”,“”] 我想在一个新的选项卡中打开它们。我正在使用的代码只是将所有URL放在一起,并试图在一个URL中打开它 非常感谢您的帮助 $.each( myArray, function( intIndex, objValue ){ window.open(myArray); } );

我有一个类似的数组

myArray=[“”,“”]

我想在一个新的选项卡中打开它们。我正在使用的代码只是将所有URL放在一起,并试图在一个URL中打开它

非常感谢您的帮助

  $.each(
                myArray,
                function( intIndex, objValue ){

                    window.open(myArray);
                }
                );
  })

您正在将整个
myArray
传递到
窗口。open()
,您必须传递每个项的值

更改:

window.open(myArray);
致:

像这样:

var myArray = ["http://www.google.co.uk", "http://www.ebay.co.uk"];

$.each(myArray,function (intIndex, objValue) {

    window.open(objValue);
});
小提琴: 正确的代码是:

var myArray = ["http://www.google.co.uk", "http://www.ebay.co.uk"];
$(document).ready(function() {
$.each(
    myArray,
    function( intIndex, objValue ){
        window.open(objValue);
    });
});
您在window.open中使用了数组变量,这就是它加入URL的原因

var myArray = ["http://www.google.co.uk", "http://www.ebay.co.uk"];
$(document).ready(function() {
$.each(
    myArray,
    function( intIndex, objValue ){
        window.open(objValue);
    });
});