title: Check Id element javascript
body: <pre><code>var jewels = new Array()
  var index
  var rand
  
  var scard = [a1, a2, a3, b1, b2, b3, c1, c2, c3]
  
      function generateBoard() {
  
          for (var i = 0; i &lt;= 8; i++) {
              jewels[i] = new Array();
  
              var index = Math.floor(Math.random() * scard.length)
              jewels[i] = scard[index]
              console.log("I:" + i + jewels[i])
              var yy = scard.indexOf(scard[index]);
              scard.splice(yy, 1);
          }
      }
  
      function drawBoard() {
  
          generateBoard()
          var html = '&lt;div class=Game_Background&gt;'
  
          for (var i = 0; i &lt; 9; i++) {
  
              rand = Math.floor(Math.random() * jewels.length)
              html += '&lt;div class="' + jewels[rand] + '" id="ship' + i + '" style="top:' + ((i * 12) + 135) + 'px; left:245px;" &gt;&lt;/div&gt;'
              jewels.splice(rand, 1);
          }
          var newarray = [a1, a2, a3, b1, b2, b3, c1, c2, c3]
      }
  </code></pre>
  
  <p>here a1,a2,a3,b1,b2,b3,c1,c2,c3 are css class.I use the newarray because I splice all the array items.Now Suppose the element of ship2 id is b3 and b3 is positioned in newarray[5]. How I check this(the id element is positioned in which number of index in the array)?</p>