JSFiddle - React, Tailwind, and code Playground

HTML

<a id="previous" href="#">prev</a>

<div id="r"></div>

JavaScript

// this method is just to display the results
function show(s)
{
  $("#r").append((s == undefined ? "undefined" : s));
  $("#r").append("<br/>");
}

// Try to retrieve the control attribute
// returns undefined because the attribute doesn't exists
show($("#previous").data("control"));

// Set the control data
$("#previous").data("control", "-6");

// Retrieve the control data (-6)
show($("#previous").data("control"));


show("<p><hr />From a object in data</p>");


// Storing an object
$("#previous").data("control", { value: -6, id: 2 });

// Retriving the object
show(".value is: " + ($("#previous").data("control")).value); // -6
show(".id is: " + ($("#previous").data("control")).id); // 2