Javascript assigning event handlers via for loop

前端 未结 1 489
名媛妹妹
名媛妹妹 2021-01-24 12:11

Apologies if I appear a little \"noobish\" with events, but for whatever reason the following doesn\'t work for me:

var someDomRef = document.getElementByRef(\"r         


        
1条回答
  •  心在旅途
    2021-01-24 12:37

    i is undefined when mouseup is called. You need to close over this with some closure functions:

    var someDomRef = document.getElementByRef("refVal");
    for(i=0;i

    You may need another closure inside of the onmouseup function

    0 讨论(0)
提交回复
热议问题