> 文档中心 > JS的简单点击事件

JS的简单点击事件


场景需求:点击右边的图片,左边也跟着换,包括mp4 

                 .allImg {     width: 950px;     height: 583px;     margin: 0 auto;     border: 1px solid rgb(174, 186, 197); } .bigImg {     position: relative;     top: 0;     left: 0;     width: 783px;     height: 570px;     padding: 6px;     float: left; } .bigImg img, .bigImg video {     width: 100%;     height: 100%;     cursor: pointer; } .smallImg {     width: 155px;     height: 600px;     padding-top: 6px;     float: right; } .smallImg div {     position: relative;     top: 0;     right: 0; } .smallImg li {     list-style: none; } .smallImg img, .smallImg video {     width: 148px;     height: 109px;     border: 1px solid rgb(174, 186, 197);     cursor: pointer; }        
JS的简单点击事件
  • JS的简单点击事件
  • JS的简单点击事件
  • JS的简单点击事件
  • JS的简单点击事件
  • window.ImgClick = function (i, str) { let srcData = 'img/' + i; let imgShow = $('#img_show'); let videoShow = $('#video_show'); if (str === 'mp4') { imgShow[0].style.display = 'none'; videoShow[0].style.display = 'block'; videoShow.attr('src', srcData + '.mp4'); } else { imgShow[0].style.display = 'block'; videoShow[0].style.display = 'none'; imgShow.attr('src', srcData + '.jpg'); videoShow.attr('src', ''); } };

     效果图