<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
图片垂直居中 function test(id) { var div1 = document.getElementById(id); var div2 = document.createElement("div"); div2.setAttribute("style","border:1px solid red;width:30px;height:20px;margin:3px;"); div2.setAttribute("onclick","javascript:alert('提示消息!');"); div1.insertBefore(div2, div1.firstChild); }
</div>