I'm trying to set an attribute to an element that has multiple values. Is it possible?
I want to get the div element size (height, width) and set it inside an array and then set the array as the attribute value.
What I did is this:
function originBoxSize() {
each('body div', function () {
var boxSize = [$(this).css('height'), $(this).css('width')];// get the box size
$(this).attr('wcag-origin-box-size', boxSize); // set an new attr with boxsize value
});
}
Now boxSize
holds ["102px", "499px"]
The attr
looks like this:
wcag-origin-box-size="102px,499px"
When I want to get the attr
value Im typing the line:
$('#element').attr('wcag-origin-box-size')
The result is this : "102px,499px"
which is a string.
Is there a way to get only specific value from the attribute (height or width)?
Thanks in advance.