the id is to name an element. u should not have two elements with the same id or you will have this problem.
to fix it just change the name, maybe item 2, both on the div tag and also on the get element by id parenthesis. So in the end you will have this,
<div id="item1"><img src="it1.jpg"></div>
<input type="button" value="hide"
onClick="document.getElementById('item1').style.display= 'none';">
<div id="item2"><img src="it2.jpg"></div>
<input type="button" value="hide"
onClick="document.getElementById('item2').style.display= 'none';">