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)团队开发的一 ...
随机推荐
- 60、saleforce的future方法
测试future方法的异步执行 public with sharing class FutureSample { //future在自己线程中运行,直到资源可用才运行 @future public s ...
- 为什么对象被new 以后在执行dup操作?
为什么对象被new 以后在执行dup操作? 今天有个朋友问我,为什么一个new一个对象的指令在new后面紧跟的是dup操作?他说搜了可能找到的 搜索引擎都找不到答案,包括翻了<<深入JAV ...
- export export-default import 使用场景
export export-default import 使用场景:https://blog.csdn.net/weixin_36222137/article/details/77453774
- 开发效率优化之自动化构建系统Gradle(二)上篇
阿里P7移动互联网架构师进阶视频(每日更新中)免费学习请点击:https://space.bilibili.com/474380680 本篇文章将以下两个内容来介绍自动化构建系统Gradle: gra ...
- 深入Dagger:JavaPoet的使用
前言 最近在用Dagger开发应用,Dagger是google在square的基础上去反射的依赖注入框架. Dagger会根据定义的注解在编译阶段根据依赖注入的配置生成相应的代码,来减少运行期间反射的 ...
- 2018-8-10-win10-UWP-button
title author date CreateTime categories win10 UWP button lindexi 2018-08-10 19:16:53 +0800 2018-2-13 ...
- Shell 变量的分类
- Java工程师面试linux操作选择面试题大全
1.请写出常用的linux指令不低于10个,请写出linux tomcat启动.linux指令arch 显示机器的处理器架构(1)uname -m 显示机器的处理器架构(2)shutdown -h n ...
- python 操作redis数据
python 操作redis 各种类型的数据 # encoding:utf-8 import redis import time def main(): """ redi ...
- SQL优化(三)—— 索引、explain分析
SQL优化(三)—— 索引.explain分析 一.什么是索引 索引是一种排好序的快速查找的数据结构,它帮助数据库高效的查询数据 在数据之外,数据库系统还维护着满足特定查找算法的数据结构,这些数据 ...