[英]I am trying to make image appear onclick, and the script is not executing
I'm trying to make a separate image appear when you click an active image on a page.当您单击页面上的活动图像时,我正在尝试显示单独的图像。
I've tried moving the onclick into the <a>
tag, the <img>
tag, the <div>
tag, I've tried using different versions of this script command, nothing will seem to make it work.我尝试将 onclick 移动到<a>
标记、 <img>
标记、 <div>
标记中,我尝试使用此脚本命令的不同版本,但似乎没有任何效果。 The active images and the cursor:pointer all work, but the java is failing.活动图像和 cursor:pointer 都可以工作,但 java 失败。 Any ideas??有任何想法吗??
function opencontact() { var x = document.getElementById("instagram"); if (x.style.display === "none") { x.style.display = "inline"; } else { x.style.display = "none"; } }
.insta { display: none; position: fixed; top: 180px; right: 220px; z-index: 2; transition: 0s; padding: 0px; }
<div id="lips2" class="lipbtn2"> <span style="cursor:pointer" onclick="opencontact()"> <a> <img src="https://www.country935.ca/wp-content/uploads/sites/19/2017/07/a-kiss.jpg" width="15%" height="auto" alt="" class="kiss2"> <img src="https://dzasv7x7a867v.cloudfront.net/product_photos/34277616/20150910_011229_1000w.png" width="15%" height="auto" alt="" class="kiss2active"> </a> </span> </div> <div id="instagram" class="insta"> <a href="http://instagram.com/"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Instagram_logo_2016.svg/1200px-Instagram_logo_2016.svg.png" alt="" width="124px" /> </a> </div>
You need to turn the test around or you will have to click twice您需要翻转测试,否则您将不得不单击两次
I am not sure what else you want to happen我不确定你还想发生什么
function opencontact() { var x = document.getElementById("instagram"); x.style.display = x.style.display === "inline"? "none": "inline" }
.insta { display: none; position: fixed; top: 180px; right: 220px; z-index: 2; transition: 0s; padding: 0px; }
<div id="lips2" class="lipbtn2"> <span style="cursor:pointer" onclick="opencontact()"> <a> <img src="https://www.country935.ca/wp-content/uploads/sites/19/2017/07/a-kiss.jpg" width="15%" height="auto" alt="" class="kiss2"> <img src="https://dzasv7x7a867v.cloudfront.net/product_photos/34277616/20150910_011229_1000w.png" width="15%" height="auto" alt="" class="kiss2active"> </a> </span> </div> <div id="instagram" class="insta"> <a href="http://instagram.com/"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Instagram_logo_2016.svg/1200px-Instagram_logo_2016.svg.png" alt="" width="124px" /> </a> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.