Using Offsetx And Offsettop In JavaScript Or Position X And Positon Y
I have a slider that starts at click on button and I want every image to be loaded at a offset of 200 px in comparison with the previous one. Here is the code: var image1 = new Ima
Solution 1:
I actually don't get whats your question. Maybe you should be a bit more precise. If you want to make a picture slider, then your approach doesn't seems to be right.
Solution 2:
Hey this should work for you. I didn't had time to check it, so I hope there are no mistakes in it. Just update the JS, you can leave the html.
Regards
var images = [
'image1.jpg',
'Image2.jpg',
'...'
];
function slideit()
{
var index = 0;
var container = document.getElementById('yourContainer');
var addPic = function()
{
var img = document.createElement('img');
img.src = images[index];
img.style.position = 'absolute';
img.style.left = index * 200 + 'px';
container.appendChild(img);
index++;
}
setInterval(addPic, 1000);
}
Post a Comment for "Using Offsetx And Offsettop In JavaScript Or Position X And Positon Y"