How can I check if an element exists in the visible DOM?

How do you test an element for existence without the use of the getElementById method? I have set up a live demo for reference. I will also print the code on here as well: <!DOCTYPE html> <html> <head> <script> var getRandomID = function (size) { var str = “”, i = 0, chars = “0123456789abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ”; … Read more