web前端|js教程
javascript input file
web前端-js教程
本文实例介绍了javascript实现input file上传图片预览效果的详细代码,分享给大家供大家参考,具体内容如下
dz论坛视频源码,vscode的基础教程网站,ubuntu升级不过,tomcat登录密码加密,1688数据爬虫,php 图形编程,seo推广公司报价多少钱lzw
运行效果图:
易语言流程控制源码,ubuntu公网域名绑定,tomcat最大并发配置,爬虫谷歌翻译,php 串口数据怎么导入,彩虹seolzw
适合做流量的网站源码,ubuntu里窗口太大,tomcat免安装版区别,论坛 图片 爬虫,php登录界面怎么登陆,湛江seo策略lzw
具体实现代码:
X
X
X
X
X
X
X
X
X
X
$(function() { $(".filepath").on("change",function() { alert($(.imgbox).length); var srcs = getObjectURL(this.files[0]); //获取路径 $(this).nextAll(".img1").hide(); //this指的是input $(this).nextAll(".img2").show(); //fireBUg查看第二次换图片不起做用 $(this).nextAll(.close).show(); //this指的是input $(this).nextAll(".img2").attr("src",srcs); //this指的是input $(this).val(\); //必须制空 $(".close").on("click",function() { $(this).hide(); //this指的是span $(this).nextAll(".img2").hide(); $(this).nextAll(".img1").show(); }) }) })function getObjectURL(file) { var url = null; if (window.createObjectURL != undefined) { url = window.createObjectURL(file) } else if (window.URL != undefined) { url = window.URL.createObjectURL(file) } else if (window.webkitURL != undefined) { url = window.webkitURL.createObjectURL(file) } return url };$(function() { $("#img").on("change",".filepath1",function() { //alert($(.imgbox1).length); var srcs = getObjectURL(this.files[0]); //获取路径 alert(srcs); //this指的是input /* $(this).nextAll(".img22").attr("src",srcs); //this指的是input $(this).nextAll(".img22").show(); //fireBUg查看第二次换图片不起做用*/ var htmlImg=
+
+\+X+\+\+
+
; $(this).parent().parent().before(htmlImg); $(this).val(\); //必须制空 $(this).parent().parent().prev().find(".img11").hide(); //this指的是input $(this).parent().parent().prev().find(.close1).show(); $(".close1").on("click",function() { $(this).hide(); //this指的是span $(this).nextAll(".img22").hide(); $(this).nextAll(".img11").show(); if($(.imgbox1).length>1){$(this).parent().parent().remove(); } }) }) })
更多javascript实现input file上传图片预览效果相关文章请关注PHP中文网!