How to Get Element By Class in JavaScript?

前端 未结 11 2372
南旧
南旧 2020-11-22 01:48

I want to replace the contents within a html element so I\'m using the following function for that:

function ReplaceContentInContainer(id,content) {
   var c         


        
11条回答
  •  死守一世寂寞
    2020-11-22 02:18

    A Simple and an easy way

    var cusid_ele = document.getElementsByClassName('custid');
    for (var i = 0; i < cusid_ele.length; ++i) {
        var item = cusid_ele[i];  
        item.innerHTML = 'this is value';
    }
    

提交回复
热议问题