触发别的按钮的onclick事件
<html>
<head>
<title>dddd</title><script type="text/javascript">
function trigbutton(){
var comment = document.getElementById('button2');
if (document.all) {
// For IE
comment.click();
}
else if (document.createEvent) {
//FOR DOM2
var ev = document.createEvent('HTMLEvents');
ev.initEvent('click', false, true);
comment.dispatchEvent(ev);
}
}
function trigselect(){
var comment = document.getElementById('button3');
comment.click();
}
</script>
</head>
<body>
<select size="1" name="D1" id="select1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<input type="button" value="button1" onclick="alert('button1');trigbutton();"/>
<input type="button" value="button2"id="button2" onclick="alert('button2');trigselect();"/>
<input type="button" value="button3"id="button3" onclick="alert('button3');"/>
</body>
</html>