Javascript - Dynamically assign onclick event in the loop

前端 未结 7 1085
无人共我
无人共我 2020-11-27 19:38

I have very simple html page with js code:


    
        
    
    

        <         


        
相关标签:
7条回答
  • 2020-11-27 20:36

    You'll have to do something like this:

    btnShow.onclick = (function(opt) {
        return function() {
           showParam(opt);
        };
    })(arrOptions[i]);
    
    0 讨论(0)
提交回复
热议问题