이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 참여해서 번역을 마치도록 도와 주세요!
English (US)의 문서도 읽어보세요.

A global event handler for the dragenter event.


var dragenterHandler = targetElement.ondragenter;

Return value

The dragenter event handler for element targetElement.


This example demonstrates using the ondragenter attribute handler to set an element's dragenter event handler.

<!DOCTYPE html>
<html lang=en>
<title>Examples of using the Drag and Drop Global Event Attribute</title>
<meta content="width=device-width">
  div {
    margin: 0em;
    padding: 2em;
  #source {
    color: blue;
    border: 1px solid black;
  #target {
    border: 1px solid black;
function dragstart_handler(ev) {
 // Change the source element's background color to signify drag has started = "dashed";

function dragover_handler(ev) {
 // Change the target element's border to signify a drag over event
 // has occurred = "lightblue";

function drop_handler(ev) {
 var data = ev.dataTransfer.getData("text");;

function dragenter_handler(ev) {
 // Change the source element's background color for enter events = "yellow";

function dragleave_handler(ev) {
 // Change the source element's border back to white = "white";

function dragend_handler(ev) {
 // Change the target element's background color to visually indicate 
 // the drag ended.
 var el=document.getElementById("target"); = "pink";

function dragexit_handler(ev) {
 // Change the source element's border back to green to signify a dragexit event = "green";

function init() {
 // Set handlers for the source's enter/leave/end/exit events
 var el=document.getElementById("source");
 el.ondragenter = dragenter_handler;
 el.ondragleave = dragleave_handler;
 el.ondragend = dragend_handler;
 el.ondragexit = dragexit_handler;
<body onload="init();">
<h1>Examples of <code>ondragenter</code>, <code>ondragleave</code>, <code>ondragend</code>, <code>ondragexit</code></h1>
   <p id="source" ondragstart="dragstart_handler(event);" draggable="true">
     Select this element, drag it to the Drop Zone and then release the selection to move the element.</p>
 <div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</div>


Specification Status Comment
HTML Living Standard
The definition of 'ondragenter' in that specification.
Living Standard  
HTML 5.1
The definition of 'ondragenter' in that specification.
Recommendation Initial definition

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
ondragenterChrome Full support 4Edge Full support YesFirefox Full support 3.5IE Full support 10Opera Full support 12Safari Full support 3.1WebView Android No support NoChrome Android No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android ?


Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also

문서 태그 및 공헌자

이 페이지의 공헌자: mdnwebdocs-bot, fscholz, rolfedh, Sebastianz, AFBarstow
최종 변경자: mdnwebdocs-bot,