Teach me not to read carefully!
You omitted a very important variable assignment and then misused a variable.
Code:
<html>
<head>
<script>
function doit()
{
// you MUST assign the collection of <div>s to a variable!
var divs = document.getElementsByTagName("div");
// you must search *IN* that collection!
for ( var x = 0; x < divs.length; x++ )
{
// and must get one member of that collection:
var div = divs[x];
if ( div.className.indexOf("single-journal-entry-wrapper") >= 0 )
{
alert("Found this: " + div.innerHTML );
// try un-commenting next line to see the difference
// break;
}
}
}
window.onload = doit;
</script>
</head>
<body>
<div class="whompit">
should not find this
</div>
<div class="whompit single-journal-entry-wrapper">
should find this first
</div>
<div class="single-journal-entry-wrapper">
should ALSO find this if you omit the break
</div>
</body>
</html>