【问题标题】:Resetting CSS when leaving drop area (drag and drop uploading)离开放置区时重置 CSS(拖放上传)
【发布时间】:2012-06-02 13:43:50
【问题描述】:

在我的应用程序中,我实现了拖放上传。当您在“放置区域”上拖动并按住图像时,放置区域会改变外观,并且会显示一条文本告诉您放置文件。

如果我取消删除文件,新的 CSS 和文本仍然存在,我需要刷新页面以使其恢复正常。如何在不刷新页面的情况下将 css 重置为正常状态?

提前致谢!

holder.ondragover = function () {
  var information = "<div id='infoText2'>" + "<span>Drop the image here!</span>";
  $('#holder').html(information);
  this.className = 'hover';
  return false;
};
// Rest of the code

【问题讨论】:

    标签: jquery image html drag-and-drop


    【解决方案1】:

    当您收到ondragend 事件时,您可以尝试删除 div 并删除类名

    holder.ondragend = function () {
      $('#intoText2').remove();
      this.removeClass();
    };
    

    【讨论】:

    • 您的代码运行良好,但您应该使用 ondragleave 而不是 ondragend。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多