JS继承示例

来源:互联网 发布:java的jdk和jre 编辑:程序博客网 时间:2024/06/02 04:33

image-file-visible-init.js内容如下:

$(document).ready(function(){$.imageFileVisible({wrapSelector: ".upload-image-show1",   fileSelector: ".upload-image-file2 .file",width: "100%",height: "100%"});});

image-file-visible.js内容如下:

(function($) {       $.imageFileVisible = function(options) {     var defaults = {      wrapSelector: null,    //<input type="file">  fileSelector:  null ,  width : '100%',  height: 'auto',  errorMessage: "错误" };     // Extend our default options with those provided.    var opts = $.extend(defaults, options);      $(opts.fileSelector).on("change",function(){var file = this.files[0];var imageType = /image.*/;if (file.type.match(imageType)) {var reader = new FileReader();reader.onload = function(){var img = new Image();img.src = reader.result;$(img).width( opts.width);$(img).height( opts.height);$( opts.wrapSelector ).empty(); $( opts.wrapSelector ).append(img); /* $( opts.wrapSelector ).html(img);*/};reader.readAsDataURL(file);}else{alert(opts.errorMessage);}});};     })(jQuery);

参考链接:http://www.cnblogs.com/liqforstudy/articles/5291077.html