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

 时间:2026-02-17 12:50:31

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
  • 热门搜索
    眼睛充血是什么原因引起的起的 庶女古代好生活手札 飞雕开关插座怎么样 如何治疗静脉曲张 河北建筑工程学院怎么样 美妙生活 怎么群发qq消息 电脑密码忘了怎么解锁 血红蛋白高是什么原因 泰捷怎么看电视直播