We would like to know how to get next/previous element.
<!DOCTYPE html>
<html>
<body>
<div id="a">A</div>
<div id="b">B</div>
<div id="c">c</div>
<br />
<div id="result">Result:</div>
<!--from ww w.j av a 2 s. c o m-->
<script type='text/javascript'>
var b = document.getElementById("c").previousElementSibling;
document.getElementById("result").innerHTML += b.innerHTML;
</script>
</body>
</html>
The code above is rendered as follows: