Javascript - Dynamically assign onclick event in the loop

前端 未结 7 1120
无人共我
无人共我 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]);
    

提交回复
热议问题