I'm puzzled by how these two javascript/css codes can yield different results:
1st:
prev.setAttribute('style', 'position:absolute;left:-70px;opacity:0.4;border-radius: 150px;-webkit-border-radius: 150px;-moz-border-radius: 150px;');
2nd:
prev.setAttribute('style', 'opacity:0.4;border-radius: 150px;-webkit-border-radius: 150px;-moz-border-radius: 150px;');
prev.setAttribute('height', size);
prev.setAttribute('width', size);
prev.setAttribute('id', 'thumb'+i);
prev.setAttribute('position', 'absolute');
prev.setAttribute('left', '-70px');
In the 2nd code block, the properties position and left seem to be ignored entirely. The resulting output remains the same whether those lines of code are present or absent.
It seems that prev.style.left
is necessary for it to work, similar to the behavior with the position property. However, using setAttribute does work for setting height and width. I'm really curious to understand why this difference occurs.