How to Find Visible HTML Element by class in JavaScript?
We can use the same logic jQuery uses with this code:
element.offsetWidth > 0 && element.offsetHeight > 0;
You can simply go through the list of your class elements to find the one currently displayed.
for (var i = 0; i < document.getElementsByClassName('myclass').length; i++) { if (document.getElementsByClassName('myclass')[i].offsetWidth > 0 && document.getElementsByClassName('myclass')[i].offsetHeight > 0) { //found the visible element of class 'myclass' break; } }