js控制图片放大缩小的简易版

js代码:

function bb_img_onmousewheel(e, o) {
    var zoom = parseInt(o.style.zoom, 10) || 100;
    zoom += event.wheelDelta / 12;
    if (zoom > 0) o.style.zoom = zoom + '%';
    return false;
}

图片html标签:

<img onmousedown="if(self.startMove)startMove(this,event)" onmousewheel="return bb_img_onmousewheel(event,this)" style="cursor: move; zoom: 80%;" src="" width="600px" />

 

posted @ 2016-10-20 12:02  青衫仗剑  阅读(293)  评论(0编辑  收藏  举报