jQuery用戶頭像裁剪插件cropbox.js使用詳解
更新時間:2017年06月07日 10:45:29 作者:pengjunhao
這篇文章主要為大家詳細(xì)介紹了jQuery用戶頭像裁剪插件cropbox.js的使用方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
幾乎每一個網(wǎng)頁是必備圖片上傳,圖片裁剪功能,這里通過cropbox.js插件實現(xiàn)該功能。
<script src="js/jquery-1.11.1.min.js"></script> <script src="js/cropbox.js"></script> <script type="text/javascript"> $(window).load(function() { var options = { thumbBox: '.thumbBox', spinner: '.spinner', imgSrc: 'images/avatar.png' } var cropper = $('.imageBox').cropbox(options); $('#file').on('change', function(){ var reader = new FileReader(); reader.onload = function(e) { options.imgSrc = e.target.result; cropper = $('.imageBox').cropbox(options); } reader.readAsDataURL(this.files[0]); this.files = []; }) $('#btnCrop').on('click', function(){ var img = cropper.getDataURL(); $('.cropped').append('<img src="'+img+'">'); }) $('#btnZoomIn').on('click', function(){ cropper.zoomIn(); }) $('#btnZoomOut').on('click', function(){ cropper.zoomOut(); }) }); </script>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
jQuery+css實現(xiàn)百度百科的頁面導(dǎo)航效果
這篇文章主要介紹了jQuery+css實現(xiàn)百度百科的頁面導(dǎo)航效果,需要的朋友可以參考下2014-12-12