jQuery基于svg图片上传预览代码

 时间:2026-04-26 01:47:50

1、新建html文档。

jQuery基于svg图片上传预览代码

3、书写css代码。<style type="text/css">body { background: #efd; }section { width: 1200px; margin: 200px auto; }article { border: 1px solid #ccc; padding: 20px; }.icon { width: 2em; height: 2em; vertical-align: -0.15em; fill: currentColor; overflow: hidden; }.item { float: left; position: relative; margin: 20px; }.addImg { width: 190px; height: 190px; }.upload_input { display: none; }.preview { position: absolute; width: 190px; height: 190px; left: 0; top: 0; }.click { position: absolute; width: 190px; height: 190px; left: 0; top: 0; z-index: 1; cursor: pointer; }.delete { position: absolute; right: -2rem; top: -1rem; cursor: pointer; display: none; }.preview img { width: 100%; height: 100%; }</style>

jQuery基于svg图片上传预览代码

4、书写并添加js代码。<script>  //选择图片  var loadImg = function(obj){    $(obj).parent().find(".upload_input").click();  }  //删除  var deleteImg = function(obj){    $(obj).parent().find('input').val('');    $(obj).parent().find('.preview').html('');    $(obj).hide();  }</script>

jQuery基于svg图片上传预览代码

5、代码整体结构。

jQuery基于svg图片上传预览代码

6、查看效果。

jQuery基于svg图片上传预览代码

  • svg文件怎么打开
  • jquery图片上传插件教程
  • jQuery多张图片上传如何设置
  • android的SVG的使用步骤
  • Qt如何使用SVG
  • 热门搜索
    如何下象棋 佛山西站在哪里 六盘山在哪里 怎么分辨玉的好坏 宁波高铁站在哪里 hp笔记本怎么进bios 无线路由器怎么安装 红米手机质量怎么样 黑龙江农垦职业学院怎么样 皮肤如何补充胶原蛋白