Hi all,
I have an array of data that I'll echo to a page using PHP, and I want JQuery to be able to parse it. However, I don't want the data necessarily visible to the user. I have, for example:
<div id="data-1">
<span id="width">5</span>
<span id="height">10</span>
<span id="depth">15</span>
</div>
<div id="data-2">
<span id="width">10</span>
<span id="height">20</span>
<span id="depth">30</span>
</div>
I'm wondering if I should be storing data in spans this way, and then in JQuery, hiding them onload and play with the data by getting the span values later:
$(document).ready( function() {
$("#width, #height, #depth").hide();
$("#data-*").click(function() {
var width = $("#width", $(this)).text();
var height = $("#height", $(this)).text();
var depth = $("#depth", $(this)).text();
});
});
Is this the most efficient way to store data on the page? Should I be using instead, hidden inputs, or are there other ways to do this? Thanks!