2 回答

TA貢獻(xiàn)1864條經(jīng)驗(yàn) 獲得超2個(gè)贊
試試下面的代碼
<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>

TA貢獻(xiàn)1856條經(jīng)驗(yàn) 獲得超5個(gè)贊
嘿伙計(jì)們,這里是答案,但我不知道為什么要寫兩次腳本標(biāo)簽。有人可以解釋一下嗎?
<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>
添加回答
舉報(bào)