Customize the list of registered right-events

Circulation list because each one requires registration

$ ( "# Num"). Val () the total number of

$("#fileList-" + i).attr("data-id");主键

window.onload = function () {
  for (var i = 0; i < $("#num").val() ; i++) {
    document.getElementById("fileList-" + i).oncontextmenu = function (e) {
    e.preventDefault();
    };
    debugger;
    var id = $("#fileList-" + i).attr("data-id");
    //自己定义事件的函数
    document.getElementById("fileList-" + i).onmouseup = function (oEvent) {
      if (!oEvent) oEvent = window.event;
        if (oEvent.button == 2) {
          alert(id)
        }
    }
  }
}

Guess you like

Origin www.cnblogs.com/otsf/p/11249352.html