【发布时间】:2019-01-03 21:24:20
【问题描述】:
我对编码完全陌生,我想知道如何编写一个链接,该链接在显示隐藏图像的同时使用 HTML 隐藏自身。根据我收集到的信息,这应该可行:
<a href="javascript:onoff()" id="QRText" onclick="myFunction();"=>Click to reveal QR code</a>
<img hidden alt="QR Code" id="revealonclick" src="https://erallie.weebly.com/uploads/1/1/8/6/118611729/published/qr-code-erallie-s-app.png?1532624405">
<script>
function myFunction() {
alert("The app is in the form of a webpage. Don't forget to add the webpage to your homescreen!");
</script>
<script type="text/javascript">
function onoff() {
if (document.getElementById)
document.getElementById("QRText").style.visibility = "hidden";
if (document.getElementById)
document.getElementById("revealonclick").style.visibility = "visible";
}
</script>
隐藏链接有效,通知有效,但由于某种原因,当我尝试将多个参数添加到一个函数中时,它似乎不起作用。我做错了什么?
【问题讨论】:
-
您的函数
myFunction中存在语法错误。这是你的完整代码吗?
标签: javascript html visibility