function $id(id)
{return document.getElementById(id);};
for(x = 1;x < 4;x++)
{
$id("button_img_"+x).addEventListener("click",slide_button);
}
如上述代码,id需要被遍历,如何让document.getElementById("id")里的id为变量?
谢谢
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你现在这样遍历没有问题呀,这样可以传一个变量id进去。