技术员联盟提供win764位系统下载,win10,win7,xp,装机纯净版,64位旗舰版,绿色软件,免费软件下载基地!

当前位置:主页 > 教程 > 服务器类 >

jQuery用户头像裁剪插件cropbox.js如何使用

来源:技术员联盟┆发布时间:2017-08-06 06:38┆点击:

几乎每一个网页是必备图片上传,图片裁剪功能,这里通过cropbox.js插件实现该功能。

<script src=http://www.3lian.com/edu/2017/06-08/"js/jquery-1.11.1.min.js"></script> <script src=http://www.3lian.com/edu/2017/06-08/"js/cropbox.js"></script> <script type=http://www.3lian.com/edu/2017/06-08/"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=http://www.3lian.com/edu/2017/06-08/"'+img+'">'); }) $('#btnZoomIn').on('click', function(){ cropper.zoomIn(); }) $('#btnZoomOut').on('click', function(){ cropper.zoomOut(); }) }); </script>