我是 jQuery 和编程新手,如何检查两个数组元素是否属于同一个数组。我这样做了..但它不起作用
var blackCoins = ["♚", "♛", "♜", "♝", "♞", "♟"];
var whiteCoins = ["♔", "♕", "♖", "♗", "♘", "♙"];
var buffer = $("myselector1").text();
var storeBuffer = $("#myselector2").text();
var flag = 0;
if ($.inArray(buffer, whiteCoins) > -1 && $.inArray(storeBuffer, whiteCoins) > -1){
flag = 1;
}
else if($.inArray(buffer, blackCoins) > -1 && $.inArray(storeBuffer, blackCoins) > -1) {
flag = 1;
}
}
如果需要,我可以提供更多信息..