jQuery实用美化input 上传组建
简要教程
jquery-filestyle是一款可以简单实用的表单文件上传域美化jQuery插件。该插件可以将表单的文件上传域转换为类似Bootstrap按钮组的样式。它提供了大量的data属性来控制文件上传域的样式,可以自定义按钮文本和图标等。
使用方法
使用该表单文件上传域美化插件需要引入jquery,jquery-filestyle.min.css和jquery-filestyle.min.js文件。
<link href="css/jquery-filestyle.min.css"><script src="js/jquery.js"></script><script src="js/jquery-filestyle.min.js"></script> |
HTML结构
最简单的使用方法是在<input>元素中使用data属性来直接转换文件上传域。
<input type="file" class="jfilestyle" data-theme="blue" data-input="false"> |
应用举例
将input元素进行转换
将一个普通的<input>元素进行美化。
javascript方法:
$(":file").jfilestyle({input: false}); |
通过data属性:
<input type="file" class="jfilestyle" data-input="false"> |
按钮文本
改变按钮上的文本。默认值为:"Choose file"。
javascript方法:
$(":file").jfilestyle({buttonText: "查找文件"}); |
通过data属性:
<input type="file" class="jfilestyle" data-buttonText="查找文件"> |
禁用状态
设置文件选择为禁用状态。
javascript方法:
$(":file").jfilestyle({disabled: true}); |
通过data属性:
<input type="file" class="jfilestyle" data-disabled="true"> |
禁用状态
选择文件按钮在输入框的前面。
javascript方法:
$(":file").jfilestyle({buttonBefore: true}); |
通过data属性:
<input type="file" class="jfilestyle" data-buttonBefore="true"> |
输入框的尺寸
设置文件选择域的尺寸。使用CSS测量单位,默认值为200px。
javascript方法:
$(":file").jfilestyle({inputSize: "350px"}); |
通过data属性:
<input type="file" class="jfilestyle" data-inputSize="400px"> |
文本占位
设置输入框的文本占位。
javascript方法:
$(":file").jfilestyle({placeholder: "My place holder"}); |
通过data属性:
<input type="file" class="jfilestyle" data-placeholder="文本占位字符"> |
使用图标
javascript方法:
$(":file").jfilestyle({buttonText: "<span class='glyphicon glyphicon-folder-open'></span>"}); |
通过data属性:
<input type="file" class="jfilestyle" data-buttonText="<span class='glyphicon glyphicon-folder-open'></span>"> |
方法
clear:清空选择的文件。$(":file").jfilestyle('clear');destroy:销毁对象实例。$(":file").jfilestyle('destroy');input:设置或获取输入域的内容。// 获取$(":file").jfilestyle('input');// 设置$(":file").jfilestyle({'input':false});buttonText:设置或获取按钮上的文本。// 获取$(":file").jfilestyle('buttonText');// 设置$(":file").jfilestyle({'buttonText':'My text'});disabled:设置按钮为不可用或获取按钮状态是否为不可用。// 获取$(":file").jfilestyle('disabled');// 设置$(":file").jfilestyle({'disabled':true});buttonBefore:设置按钮在输入框前面或获取按钮的位置。// 获取$(":file").jfilestyle('buttonBefore');// 设置$(":file").jfilestyle({'buttonBefore':true});inputSize:设置或获取输入框的尺寸。// 获取$(":file").jfilestyle('inputSize');// 设置$(":file").jfilestyle({'inputSize':'400px'});placeholder:设置或获取占位文本。// 获取$(":file").jfilestyle('placeholder');// 设置$(":file").jfilestyle({'placeholder':'My text placeholder'});
jQuery实用美化input 上传组建的更多相关文章
- input上传按钮美化
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- css input[type=file] 样式美化,input上传按钮美化
css input[type=file] 样式美化,input上传按钮美化 参考:http://www.haorooms.com/post/css_input_uploadmh
- jQuery文件上传插件jQuery Upload File 有上传进度条
jQuery文件上传插件jQuery Upload File 有上传进度条 jQuery文件上传插件jQuery Upload File,插件使用简单,支持单文件和多文件上传,支持文件拖拽上传,有进度 ...
- 【转】JQuery插件ajaxFileUpload 异步上传文件(PHP版)
前几天想在手机端做个异步上传图片的功能,平时用的比较多的JQuery图片上传插件是Uploadify这个插件,效果很不错,但是由于手机不支持flash,所以不得不再找一个文件上传插件来用了.后来发现a ...
- 转: 如何实现jQuery的Ajax文件上传
[PHP文件上传] 在开始之前,我觉得是有必要把通WEB上传文件的原理简单说一下的.实际上,在这里不管是PHP,JSP,还是ASP处理上传的文件,其实都是WEB早已把文件上传到服务器了,我们只是运用上 ...
- jQuery插件AjaxFileUpload文件上传实现Javascript多文件上传功能
Ajax file upload plugin是一个功能强大的文件上传jQuery插件,可自定义链接.或其它元素庖代传统的file表单上传结果,可实现Ajax动态提示文件上传 过程,同时支撑多文 ...
- JQuery插件ajaxFileUpload 异步上传文件(PHP版)
太久没写博客了,真的是太忙了.善于总结,进步才会更快啊.不多说,直接进入主题. 前几天想在手机端做个异步上传图片的功能,平时用的比较多的JQuery图片上传插件是Uploadify这个插件,效果很不错 ...
- input上传限定文件类型
input上传限定文件类型 accept="image/*" 限定为只能上传图片 accept=”audio/* 限定为只能上传音频 accept=”video/*” 限定 ...
- jquery组件WebUploader文件上传用法详解
这篇文章主要为大家详细介绍了jquery组件WebUploader文件上传用法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 WebUploader是由Baidu WebFE(FEX)团队开发的一 ...
随机推荐
- 数据访问层的基类BaseDALSQL
using System; using System.Text; using System.Collections; using System.Data; using System.Data.Comm ...
- 多条件异步搜索+分页(PHP、 AJAX、ThinkPHP)
项目中遇到的多条件异步查询及数据分页问题,做了数次尝试,最终虽目的达到,略有繁琐,希望能有更好的处理方式 基于 tp框架 1.html页面代码 <div class="h_cityNa ...
- Rust <4>:所有权、借用、切片
tips:栈内存分配大小固定,访问时不需要额外的寻址动作,故其速度快于堆内存分配与访问. rust 所有权规则: 每一个值在任意时刻都有且只有唯一一个所有者 当所有者离开作用域时,这个值将被丢弃 所有 ...
- Git操作思维导图
转自:https://blog.csdn.net/mynameishuangshuai/article/details/51657324
- export export-default import 使用场景
export export-default import 使用场景:https://blog.csdn.net/weixin_36222137/article/details/77453774
- vue.js实现点击后动态添加class及删除同级class
最近使用vue需要实现一个点餐选择商品规格的页面,需要通过vue动态的给被点击的元素添加class名字,使其变色,其他的删除class.如图: 开始在网上找了许多办法发现不是太好用,最后找到一个发现还 ...
- spring中@注解的相关解释
@Component:@Controller:@Service:@Repository 在annotaion配置注解中用@Component来表示一个通用注释用于说明一个类是一个spring容器管理的 ...
- spring security 学习二
doc:https://docs.spring.io/spring-security/site/docs/ 基于表单的认证(个性化认证流程): 一.自定义登录页面 1.在securityConfigy ...
- 单链表的java实现
class LNode { public LNode next; public int data; } class Lianbiao { private static LNode head = new ...
- react 小技巧
1.当从redux里异步获取数据时,在render里渲染dom会出现数据还未获取到的情况,这时可以用 usableSchemas.data.vertexes && usableSche ...