JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" name="a" class="a" value="1" />
<a href="#" class="cl">Click</a>

JavaScript

$('.cl').click(function(){
var selected_locations;
var loc_id = $('.a').val();
alert(loc_id);
selected_locations.push(loc_id);
alert(selected_locations);
});