JSFiddle - React, Tailwind, and code Playground

by fiddleyetu

HTML

<div class="gallerypreview" id="1">1</div>
<div class="gallerypreview" id="2">2</div>
<div class="gallerypreview" id="3">3</div>

JavaScript

var images = new Array(), current;

$(document).ready( function(){

    $('.gallerypreview').each(function() {
        images.push($(this).attr("id"));
    });
    
    $('.gallerypreview').on('click', function() {
        current = this.id;
        alert( current );
    });

});