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)团队开发的一 ...
随机推荐
- browser-sync浏览器同步刷新工具
> https://browsersync.io1. 安装browser-sync2. 切换到相应的目录,要监视的文件目录3. 启动browser-sync监视css文件: `browser-s ...
- Django框架(二十五)—— Django rest_framework-路由控制与响应器
路由控制与响应器 一.路由控制 # 1.基本路由: url(r'^publish/$', views.PublishView.as_view()), # 2.半自动路径:views.PublishVi ...
- angularJS CDN
http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js
- WEB前端资源集
原出处:http://www.cnblogs.com/zhengjialux/archive/2017/01/16/6291394.html 资源网站篇 CSDN:全球最大中文IT社区,为IT专业技术 ...
- React-Native 指定模拟器RUN-IOS
react-native run-ios --simulator "iPhone 7”
- 区别:javascript:void(0);javascript:;
2015-07~2015-08 区别:javascript:void(0);javascript:; href="#",包含了一个位置信息.默认的锚是#top,也就是网页的上端. ...
- CG-CTF misc部分wp
将Misc剥离出来了,已完结(coding gay不想做了) MISC1,图种一听图种,现将图片的GIF改为zip,然后解压得到另一张动图看动图最后一句话为‘都深深的出卖了我’,得到 flag2, 丘 ...
- window 下搭建流媒体服务器ffmpeg nginx-rmtp-module
媒体介绍和需要下载需要软件 1.FFmpeg是一套可以用来记录.转换数字音频.视频,并能将其转化为流的开源计算机程序.在这里我只用到了它的视屏格式转换功能,将rtsp协议的视频流转成rtmp 2.ng ...
- 【记录】eclipse / STS 设置注释模版格式/导入注释模版格式
设置注释模板的入口:Window->Preference->Java->Code Style->Code Template 将如下保存在新创建的xml文件中,导入进去 < ...
- ubuntu18.4 搭建lamp环境
一.Apache2 web服务器的安装: 可以先更新一下服务器(可选) 1.sudo apt update # 获取最新资源包 2.sudo apt upgrade ...