JSFiddle - React, Tailwind, and code Playground
HTML
<div id="a">First</div>
<div id="b">Second</div>
CSS
div {
background-color: green;
margin: 10px;
padding: 10px;
}
p {
margin: 5px 0;
font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;
}
JavaScript
var a = $("#a");
var b = $("#b");
a.data("helo", "world");
b.data("wazz", "up");
log("$.expando is " + $.expando);
var cacheIndexOfA = a[0][$.expando];
var cacheIndexOfB = b[0][$.expando];
log("cache index of a is " + cacheIndexOfA);
log("cache index of b is " + cacheIndexOfB);
var msgA = "$.cache[{i}]['helo']".replace("{i}", cacheIndexOfA);
var msgB = "$.cache[{j}]['wazz']".replace("{j}", cacheIndexOfB);
log(msgA + " is " + $.cache[cacheIndexOfA]['helo']);
log(msgB + " is " + $.cache[cacheIndexOfB]['wazz']);
// utility function
function log(message) {
var p = $("<p>", {
text: message
});
$('body').append(p);
}