src我正在尝试通过单击而不是鼠标移出和输入来切换图像。我有多个图像,我想切换单个产品的图像,如果按钮存在于图像的同一父 div 中,则会单击。有什么想法吗 ?
function toggleImage(thisimage) {
thisimage.toggle();
}
.prev_btn {
position: absolute;
left: 7px;
top: 30px;
bottom: 0;
width: 30px;
height: 128%;
z-index: 2;
border-style: dotted;
}
.next_btn {
position: absolute;
right: 65%;
top: 30px;
bottom: 0;
width: 30px;
height: 128%;
z-index: 2;
border-style: dotted;
}
<div id="pro"><img width="206" height="260" src="https://www.w3schools.com/html/pic_trulli.jpg" onmouseover="this.src='https://www.w3schools.com/html/img_chania.jpg'" onmouseout="this.src='https://www.w3schools.com/html/pic_trulli.jpg'">
<div class="prev_btn" onclick="toggle(this)"></div>
<div class="next_btn" onclick="toggle(this)"></div>
</div>
浮云间
慕后森
繁花如伊
相关分类