본문 바로가기
javaScript/jQuery

마우스 클릭한 위치로 이동 시키기 면서 애니메이션 효과

by mooyou 2023. 5. 29.
728x90
300x250
SMALL

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD Xhtml 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title></title>
	<style>
		* {
            margin: 0;
            padding: 0;
        }
        body {
            font-size: 9pt;
        }

        #parent1 {
            border: 1px solid #000;
            position: absolute;
            width: 500px;
            height: 400px;
            left: 50px;
            top: 50px;
        }

        #one {
            position: absolute;
            left: 50px;
            top: 100px;
            background-color: blue;
            width: 50px;
            height: 50px;
            display: block;
            border-radius: 50%;
        }

        #move {
            position: absolute;
            left: 50px;
            top: 30px;
        }
	</style>

<script type="text/javascript"  src="../../../libs/jquery-1.11.0.min.js"> </script>
<script type="text/javascript"  src="../../../libs/jquery.easing.1.3.js"> </script>

<script>
    $(document).ready(function(){   
        var $one = $("#one");

        $("#parent1").click(function(e){
            $one.animate({
                left:e.offsetX,
                top:e.offsetY
            },300, "easeOutBounce")
        })
    })  
</script>

</head>

<body>	
    <div id="parent1">
        <span id="one">
        </span>
    </div>
</body>

</html>

 

728x90
반응형
LIST

댓글