Div_Collection = document.getElementsByTagName("div");
if(Div_Collection[i].getAttribute("id") == "my_div")
Now it’s up to you and up to condition where u will call this function. In this function first of all I get all div elements and store these div elements in a Div_Collection variable that is actually playing role as an array. It’s necessary that there must be some unique thing in the div that you are going to be find, I assigned a unique ID to the div that I am going to find. In my case that div ID is my_div. After that I apply for loop on the array and then search for that specific div by ID. If that div found then I am executing another function else nothing.