I'm using a for loop to populate html table. 开发者_开发知识库How can I get the count of the all the tbody tags in tables based on its className? 
Sorry might be dumb question but couldn't find how ?
If you are using jQuery, you can do this way:
alert($('tbody.yourClass').length);
Or vanilla Javascript:
var els = document.getElementsByTagName('tbody');
var counter = 0;
for(var i = 0; i < els.length; i++){
  if (els[i].className === 'yourClass') counter++;
}
alert(counter);
In case you are not using jQuery you can try the one below:
var a = document.getElementsByTagName("TBODY");
    var len = a.length;
    var resultArr = [];
    var tBodyClassName = "something" //You can update it your className.
    for(var i=0; i<len; i++)
    {
        var b = resultArr[i];
        if(b.className == tBodyClassName)
        {
            resultArr.push(b);
        }
    }
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论