动画化onmouseover/onmouseout事件的图像 [英] To animate the image onmouseover/onmouseout event

查看:96
本文介绍了动画化onmouseover/onmouseout事件的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加图像控件并在网页中设置图片.

我想对图片进行动画处理,即:-通过使用Java脚本编程缓慢地onmouseover/onmouseout事件来增加/减小图片的大小,但不是突然增加/减小图片的大小.

我想在mouseover/onmouseout上缓慢增加/减小图片大小.

我将如何通过Java脚本解决上述问题,但不使用jquery ?????

请任何人帮助我.......

I add a image control & set the picture in web page.

I want to animate that picture, i.e.:- to increase/decrease the picture size by slowly onmouseover/onmouseout event using java scripts programming.But not a suddenly increase/decrease the size of picture.

I want to slowly increase/decrease the picture size onmouseover/onmouseout.

How will i solve that above problem by java scripts,but not using jquery?????

Please Please help me anybody .......

推荐答案

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script>
var imgObj = null;
function init(){
   imgObj = document.getElementById('is');
   imgObj.style.height =100+'px';
   i=0;
   }



function inc()
{
imgObj.style.height = parseInt(imgObj.style.height) + 5 + 'px';
i++;
if(i!=15)
{
inc_img = setTimeout(inc,30);
}
else
{
clearTimeout(inc_img);
i=0;
}
}


function dec()
{
imgObj.style.height = parseInt(imgObj.style.height) - 5 + 'px';
i++;
if(i!=15)
{
dec_img = setTimeout(dec,30);
}
else
{
clearTimeout(dec_img);
i=0;
}
}
window.onload =init;
</script>
</head>

<body>
<img src="klematis2.jpg" id="is" onmouseover="inc()" onmouseout="dec()" />
</body>
</html>


这篇关于动画化onmouseover/onmouseout事件的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆