日期:2014-05-16 浏览次数:20498 次
$("#button1").click(function () {
for (var i = 0; i < list.length; i++) {
$("#button"+i).click();
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type='text/javascript'>
$("#button1").click(function () {
for (var i = 0; i < list.length; i++) {
return (function(){
$("#button"+i).click();
})(i)
}
}
</script>
jQuery("#button1").bind("click", function () {
for (var i = 2; i < 4; i++) {
$("#button"+i).click();
}
});
<input id="button1" type="button" value="Button1"></input>
<input id="button2" type="button" value="Button2" onclick="alert(2);"></input>
<input id="button3" type="button" value="Button3" onclick="alert(3);"></input>