Я не понимаю, почему он выводит меня -1 для JQuery .inArray, я нажал на td 2. Это должно вывести 1.
Это HTML:
<table id="numberTable" class="table">
<tbody>
<tr>
<td class="red">1</td>
<td class="black">2</td>
<td class="red">3</td>
<td class="black">4</td>
<td class="red">5</td>
<td class="black">6</td>
<tr>
Сценарий:
$('table tr td').click(function(){
// Initialisation
var number = $(this).text();
// Datas
var data = new Array();
data['listBlackMethod'] = [2,4,6,8,10,11,13,15,17,20,22,24,28,29,31,33,35];
// Traitement
console.log(number);
console.log(data['listBlackMethod']);
//console.log()
console.log(jQuery.inArray(number,data['listBlackMethod']));
Выход
2 qqqspinguess.js:55:13
Array(17) [ 2, 4, 6, 8, 10, 11, 13, 15, 17, 20, … ] spinguess.js:56:13
-1 spinguess.js:58:13