// This will get the element that was just before item2 var x = document.getElementById("item2").previousElementSibling;