js如下:
<script type="text/javascript">
function changeicon(plus,subtract){
document.getElementById(plus).style.display=="none";
document.getElementById(subtract).style.display=="block";
}
</script>
html如下:
<div id="head_right">
<a href="javascript:void(0)"><img class="head_icon" id="plus" src="images/plus.png" onclick="changeicon('subtract','plus')"/></a>
<a href="javascript:void(0)"><img class="head_icon" id="subtract" src="images/subtract.png" onclick="changeicon('plus','subtract')"/></a>
</div>
css如下:
.head_icon{
height:30px;
margin-top:15px;}
#head_right{
width:51px;
height:100%;
background:url(../images/phone_head_right_bg.jpg) no-repeat;
float:right;}
js实现点击一图标显示另一图标问题,求高手解决,感激感激
答案:4 悬赏:80 手机版
解决时间 2021-12-30 00:13
- 提问者网友:原来太熟悉了会陌生
- 2021-12-29 01:42
最佳答案
- 五星知识达人网友:爱难随人意
- 2022-01-10 01:59
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
.head_icon {
height: 30px;
margin-top: 15px;
}
#head_right {
width: 51px;
height: 100%;
background: url(../images/phone_head_right_bg.jpg) no-repeat;
float: right;
}
</style>
<script type="text/javascript">
function changeicon(plus, subtract) {
document.getElementById(plus).style.display = "block";
document.getElementById(subtract).style.display = "none";
}
</script>
</head>
<body>
<div id="head_right">
<a href="javascript:void(0)">
<img class="head_icon" id="plus" src="JsLocalTest/img/news_panel_bottom.png" onclick="changeicon('subtract','plus')" /></a>
<a href="javascript:void(0)">
<img class="head_icon" id="subtract" src="JsLocalTest/img/news_bottom_03.png" onclick="changeicon('plus','subtract')" /></a>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
.head_icon {
height: 30px;
margin-top: 15px;
}
#head_right {
width: 51px;
height: 100%;
background: url(../images/phone_head_right_bg.jpg) no-repeat;
float: right;
}
</style>
<script type="text/javascript">
function changeicon(plus, subtract) {
document.getElementById(plus).style.display = "block";
document.getElementById(subtract).style.display = "none";
}
</script>
</head>
<body>
<div id="head_right">
<a href="javascript:void(0)">
<img class="head_icon" id="plus" src="JsLocalTest/img/news_panel_bottom.png" onclick="changeicon('subtract','plus')" /></a>
<a href="javascript:void(0)">
<img class="head_icon" id="subtract" src="JsLocalTest/img/news_bottom_03.png" onclick="changeicon('plus','subtract')" /></a>
</div>
</body>
</html>
全部回答
- 1楼网友:长青诗
- 2022-01-10 04:18
js那里应该是“=” 不是“=="
- 2楼网友:山河有幸埋战骨
- 2022-01-10 04:08
哪里想不通,直接点说吧,你想要的效果是怎样的??
- 3楼网友:玩家
- 2022-01-10 03:31
<div id="head_right">
<a href="javascript:void(0)"><img class="head_icon" id="plus" src="images/plus.png" onclick="changeicon('plus','subtract')"/></a>
<a href="javascript:void(0)"><img class="head_icon" id="subtract" src="images/subtract.png" onclick="changeicon('subtract','plus')"/></a>
</div>
参数写反了。。。 changeicon('plus','subtract')
<script type="text/javascript">
function changeicon(plus,subtract){
document.getElementById(plus).style.display="none";
document.getElementById(subtract).style.display="block";
}
</script>
赋值是 “=”号
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯