Assign value to arrays by index - Javascript jQuery

Javascript examples for jQuery:Array

Description

Assign value to arrays by index

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.4.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*w  w  w  .jav a 2 s  .c  o  m*/
var dType = [];
dType[100] = [$('<input>').attr({'class':'inp'}),'type:input'];
console.log(dType[100]); //entire array at 100
console.log(dType[100][0]); //first item
console.log(dType[100][1]); //second item
    });

      </script> 
 </head> 
 <body> 
  <input class="inp" type="text">  
 </body>
</html>

Related Tutorials