innerHTML not working with classname in JS

前端 未结 2 763
长发绾君心
长发绾君心 2021-01-14 14:12

My drop down List to select particular value-


                        
    
提交评论

  • 2021-01-14 14:44

    document.getElementsByClassName("catlink")is selecting all the elements in webpage as array therefore you have to use [0]

     function showDiv( discselect ) 
     { 
    
     if( discselect === 1) 
     { 
     alert(discselect); // This is alerting fine 
     document.getElementsByClassName("catlink")[0].innerHTML = "aaaaaaqwerty"; // Now working 
     } 
     }
    
    0 讨论(0)
  • 提交回复
    热议问题