Insert HTML Content form Array, Insert Array Key

by Ian Roberts

HTML

<div class="demo-container">
  <div class="demo-box">Demonstration Box</div>
</div>

JavaScript

media = [
    "new content 1",
    "new content 2",
    "new content 3"
];


         
$( "div.demo-container" ).html( "Array Content =" + " `" + media[0] + "` " + "Current Key = " + " `" +currentImageKey() + "` " );

function currentImageKey() {
    i = jQuery.inArray(media[0], media);
    return i;
};