Why isn't my JavaScript responding the way it does on jsfiddle?

OK, I figured it out. Here’s the solution.