我想更改项目被拖动到的div的背景。
我还设置了一个计数器,可以在拖动某些内容时进行更新(在我的情况下是我桌面上的文件)。计数器部分工作正常,但背景颜色不会改变。我做错了什么?
var drop = document.getElementById('drop1');
// Tells the browser that we *can* drop on this target
addEventHandler(drop, 'dragover', function (e) {
e = e || window.event; // get window.event if e argument missing (in IE)
if (e.preventDefault) {
e.preventDefault();
}
fileNumber = fileNumber + 1;
status.innerHTML = fileNumber;
$("#drop1").css("background-color",'#AA0000');
//$('drop1').css('background-color', '#AA0000');
return true;
});
,html看起来像这样
<DIV id="drop1">Drop files here
<h1 align=center>A File Preview Demo</h1>
<DIV id="status">Drag the files from a folder to a selected area ...</DIV>
<DIV id="drop2">Drop files here.</DIV>
<DIV id="list"></DIV>
<DIV id="list2"></DIV>
</DIV>
答案 0 :(得分:0)