How to count amount of child elements of a parent class

I have something like this.

function myFunction() {
  var c = document.getElementById("myID").childElementCount;
  alert(c);
}

Is there a way to do something like this?

function myFunction() {
  var c = document.getElementsByClass("myClass").childElementCount;
  alert(c);
}

Answer

There is no getElementByClass but there is getElementsByClassName. However, it returns a collection of elements because you can have multiple elements with the same class. IDs however are limited to one per document.

So if you knew the index of the element in the collection, you could do something like this:

var els = document.getElementsByClassName('myClass');
var c = els[0].childElementCount;
alert(c);