object.align=right;
We can assign left, right , top or bottom align the image. Here is an example
<html>
<head>
<title>Demo of Image align in JavaScript</title>
<script language='JavaScript' type='text/JavaScript'>
<!--
function move_img(str) {
document.getElementById('i1').align=str;
}
//-->
</script>
</head>
<body>
<img src=images/help.jpg id='i1'>
<br><br><br><br>
<input type=button onClick=move_img('left') value='Left'>
<input type=button onClick=move_img('right') value='Right'>
<br><br>
</body>
</html>
name | 24-11-2014 |
this is great method, thanks for your post, but i am using like this. img.src="captcha-demo.php?rand_number=" + (new Date()).getTime()); |
Kade | 25-11-2016 |
Works great and uses minimal code. Thank you!! |