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