javascript onclick在页面加载时发生 [英] javascript onclick happening on page load
本文介绍了javascript onclick在页面加载时发生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图创建一个简单的Javascript函数,以在单击图像时打开具有较大图像的窗口.发生的情况是此测试警报在页面加载时弹出,然后在我单击图像时不执行任何操作.这是代码
I'm trying to make a simple Javascript function to open a window with a bigger image when an image is clicked on. What happens is this test alert pops up on the page load and then does nothing when i click on the image. Here is the code
function zoom()
{
alert("test!");
}
document.getElementById("us").onclick=zoom();
推荐答案
尝试一下
function zoom()
{
alert("test!");
}
document.getElementById("us").onclick=zoom;
这篇关于javascript onclick在页面加载时发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文