以下代码实现了上述功能,虽然很简单,但是基本上说明了原理。实现更高级的功能当然还需要改进。
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <html> <head> <title>DropLayer2</title> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" Content="C#"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> <style type="text/css"> div { border-right: lightgrey thin solid; border-top: lightgrey thin solid; font-weight: bold; z-index: 2; text-transform: capitalize; border-left: lightgrey thin solid; color: white; border-bottom: lightgrey thin solid; background-color: dimgray; } </style> </head> <body> <div id="parentDiv" class="parentCss" style="width:100"> <div class="itemCss" onmouseover="InsertDiv(this)">one 1</div> <div class="itemCss" onmouseover="InsertDiv(this)">two 2</div> <div class="itemCss" onmouseover="InsertDiv(this)">three 3</div> <div class="itemCss" onmouseover="InsertDiv(this)">four 4</div> <div class="itemCss" onmouseover="InsertDiv(this)">five 5</div> <div class="itemCss" onmouseover="InsertDiv(this)">six 6</div> <div class="itemCss" onmouseover="InsertDiv(this)">seven 7</div> <div class="itemCss" onmouseover="InsertDiv(this)">eight 8</div> <div class="itemCss" onmouseover="InsertDiv(this)">nine 9</div> <div class="itemCss" onmouseover="InsertDiv(this)">ten 10</div> </div> <script language="javascript"> <!-- var obj,obj2; //引发事件对象 var IsDrag=false; //是否抓起 |