- 전체
- HTML
- Web Design (웹디자인)
- XE 응용 개발
- wordpress plugin dev
- Javascript & JavaScript Application
- MEAN Stack : full stack javascript
- angular js & ionic framework
- bootstrap
- WebGL, Three.js and Babylon.js
- restful api design
- mobile web
- node.js 응용
- Cloud Service 응용
- 웹 어셈블리 개발 [WASM, WebAssembly]
- 마이크로서비스, MSA (microservice architecture)
- WebGL / WebGPU
- next.js 개발
- micro frontend (마이크로프론트앤드)
- 전자상거래/쇼핑몰
- 서버 클라우드 (aws, azure, google)
JavaScript 자바스크립트 기본 예제(마우를 클릭드래그하여 오브젝트 이동 시키기)
2019.01.28 19:28
자바스크립트 기본 예제(마우를 클릭드래그하여 오브젝트 이동 시키기)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
#pop{ width: 100px; height: 100px; position: absolute; left: 100px; top: 100px; border: 1px solid #000000; background: #00FF00; z-index: 200;}
/* #은 #다음에 오는 id를 가진 객체만 사용 가능한 스타일*/
</style>
<script type="text/javascript">
var mx, my;
var on=0;
function move_onoff(e,chk){
var pop=document.getElementById("pop");
// offsetLeft,offsetTop : 부모요소를 기준한 좌표지점.
mx=e.clientX-pop.offsetLeft;
my=e.clientY-pop.offsetTop;
on=chk;
}
function move(e){
if(on==0)
return;
var pop=document.getElementById("pop");
var x=e.clientX-mx;
var y=e.clientY-my;
if(x>0)
pop.style.left=x+"px";
if(y>0)
pop.style.top=y+"px";
}
</script>
</head>
<body>
<div id="pop" onmousedown="move_onoff(event,1);" onmouseup="move_onoff(event,0);" onmousemove="move(event);"></div>
</body>
</html>
출처: https://tibang.tistory.com/entry/자바스크립트-기본-예제마우를-클릭드래그하여-오브젝트-이동-시키기 [T없이맑은날]
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
댓글 0
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
|---|---|---|---|---|
| 4 |
[Node.js] forever - node.js app 이 죽을경우 자동으로 재실행해주는 모듈
| 졸리운_곰 | 2017.09.26 | 635 |
| 3 |
[Node.js] proxy 환경에서 node.js 설정
| 졸리운_곰 | 2017.08.16 | 485 |
| 2 |
[Node.js] Node.js, Express, MongoDB를 이용하여 REST API 만들기
| 졸리운_곰 | 2016.06.06 | 771 |
| 1 |
Create a Web App and RESTful API Server Using the MEAN Stack
| 졸리운_곰 | 2016.06.05 | 2119 |

