In SharePoint 2013 I added a div on a default.aspx like this:
<div id="myDiv"></div>
Then I added a Script Editor web part on the page, and added this JavaScript:
var element = document.getElementById('myDiv');
alert(element);
The alert box displays null. What am I doing wrong?