I'm using $.data()
function to set the size of a div:
function init() {
comp = $("#center");
comp.data('image', {
dimensions : {
width : comp.width(),
height : comp.height(),
x0 : comp.position().left,
y0 : comp.position().top,
}
});
}
I'm retrieving the value like:
var image = comp.data('image');
alert(image.dimensions.x1);
The code is fine and it's working too. I would like to know if it is possible to do via $.attr()
function and which way would be better.