I am trying to change the style of the image to move it to the right. Clicking a button should alter the left style from a left=-275 with this snippet: document.getElementById(‘slider’).style.left=‘580px’;
I have the image styled like this to position it about halfway to the left of the div:
<style type="text/css">
#slider {
width:572px;
float:left;
position:relative;
left:-275px;
top:0;
}
</style>
The image has been coded as:
<section id="contentleft">
<article id="article1">
<input type="button" onClick="move_img1('left')" value="<=="><input type="button" onClick="move_img2('right')" value="==>">
<br>
<img id="slider" data-src="images/top-down.jpg" alt="top view">
</article>
</section>
The JS function follows:
<script>
/* http://www.plus2net.com/javascript_tutorial/image-position-demo.php */
function move_img1('left') {
document.getElementById('slider').style.left='-275px';
}
function move_img2('right') {
document.getElementById('slider').style.left='580px';
}
</script>
Right now, the image stays in the left position and the right button does not move it. Any ideas of what is wrong?