Is this most efficient way of setting a select/option box with javascript?

后端 未结 2 1937
深忆病人
深忆病人 2021-01-17 06:46

Is this most efficient way of setting a select/option box with javascript?


                        
    
提交评论

  • 2021-01-17 07:40

    If you're going for speed over code size, this tweak is slightly faster:

    var myselect=document.getElementById("sel_activity");
    var len = myselect.options.length;
    for (var i=0; i<len; i++){
    

    Minor note: You are missing a ; at the end of the first line in my snippet.

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