JSFiddle - React, Tailwind, and code Playground
HTML
<div id="content-p"></div>
JavaScript
var data = [{
GID: 900,
location: "Downtown",
description: "Garage downtown",
address: "123 Garage St."
}, {
GID: 42,
location: "Uptown",
description: "Garage uptown",
address: "124 Garage St."
}, {
GID: 12,
location: "Lefttown",
description: "Garage lefttown",
address: "125 Garage St."
}, {
GID: 443,
location: "Righttown",
description: "Garage righttown",
address: "126 Garage St."
}, ];
$(function () {
for (var i = 0; i < data.length; i++) {
var garage = data[i];
$("#content-p").append(
"<ul data-role=\"listview\">" +
"<li><a href=\"javascript:;\" id='" + garage.GID + "' class='submitID' >" +
"<h2>" + garage.location + "</h2>" +
"<p><b>" + garage.description + "</b></p>" +
"<p>" + garage.address + "</p>" +
"</a></li>" +
"</ul><br>");
}
$(".submitID").click(function () {
localStorage.setItem("garageID", $(this).attr('id'));
console.log(localStorage.garageID);
alert('ID: ' + localStorage.garageID);
});
});