[英]How do I call a LightBox on a click action?
Please bear with me but I was giving some code to launch a lighbox. 请多多包涵,但是我给出了一些代码来启动lighbox。 I need to display a lightbox when a user clicks on my link.
用户单击我的链接时,我需要显示一个灯箱。 The lightbox coded is in place already and is launched using a unique id.
编码的灯箱已经安装到位,并使用唯一的ID启动。 My example below uses (1111)
我下面的示例使用(1111)
<script src="bootstrap.js" type="text/javascript"></script>
<script type="text/javascript">
lightbox = new fusepump.lightbox.buynow(1111);
var callToActionElement = document.getElementById( "unique-btn");
callToActionElement.addEventListener("click", function()
{ lightbox.show(); //Show the lightbox } );
</script>
My link code is: 我的链接代码是:
<a href="#" id="unique-btn">Buy</a>
For some reason it's not working. 由于某种原因,它不起作用。 I think that the syntax is wrong.
我认为语法是错误的。
EDIT: you commented out the last part of your code //Show the lightbox } );
编辑:您注释掉了代码的最后一部分
//Show the lightbox } );
The brackets never get closed and the semicolon won't be at the end of your code but in the comment. 方括号永远不会闭合,分号不会在代码的末尾,而是在注释中。 Make the comment like this
/*Show the lightbox*/
像这样发表评论
/*Show the lightbox*/
You can also set an onClick attribute in which you can call the function name of your javascript function. 您还可以设置onClick属性,在其中可以调用javascript函数的函数名称。 It will look like this:
<a href="#" onclick="functionName()" id="unique-btn">Buy</a>
外观如下:
<a href="#" onclick="functionName()" id="unique-btn">Buy</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.