为了账号安全,请及时绑定邮箱和手机立即绑定

未捕获的 ReferenceError:sakla 未在 HTMLImageElement.

未捕获的 ReferenceError:sakla 未在 HTMLImageElement.

慕哥6287543 2022-01-01 18:36:26
我是 JavaScript 的新手,我收到了这个错误。下面是我的代码:<html><head>    <script type="text/javascript" src="jquery-3.4.1.min.js">        function hide() {            // some actions        }    </script></head>    <body>    <img id="myImgId" src="http://www.google.com/images/srpr/logo4w.png" onclick="hide()" style="position:absolute;opacity:0.5;left:50%;top:50%;width:50px;height:50px;margin-left:-25px;margin-top:-25px;z-index:100;"/></body>可能是什么问题呢?
查看完整描述

2 回答

?
慕斯王

TA贡献1864条经验 获得超2个赞

试试下面的代码


<html>

<head>

    <script type="text/javascript" src="jquery-3.4.1.min.js" />

    <script>

        function hide() {

            // some actions

        }

    </script>

</head>    

<body>

    <img id="myImgId" src="http://www.google.com/images/srpr/logo4w.png" onclick="hide()" style="position:absolute;opacity:0.5;left:50%;top:50%;width:50px;height:50px;margin-left:-25px;margin-top:-25px;z-index:100;"/>

</body>


查看完整回答
反对 回复 2022-01-01
?
RISEBY

TA贡献1856条经验 获得超5个赞

嘿伙计们,这里是答案,但我不知道为什么要写两次脚本标签。有人可以解释一下吗?


<html>

<head>

    <script type="text/javascript" src="jquery-3.4.1.min.js" ></script>

    <script>

        function hide() {

            var imgElem = $("#myImgId" );

            console.log("bastın");

            imgElem.css({'display': 'none' })

        }

    </script>

</head>    

<body>

    <img id="myImgId" src="http://www.google.com/images/srpr/logo4w.png" onclick="hide()" style="position:absolute;opacity:0.5;left:50%;top:50%;width:50px;height:50px;margin-left:-25px;margin-top:-25px;z-index:100;"/>

</body>


查看完整回答
反对 回复 2022-01-01
  • 2 回答
  • 0 关注
  • 164 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号