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)团队开发的一 ...
随机推荐
- jquery实现的ajax
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEnco ...
- Openstack组件部署 — Overview和前期环境准备
目录 目录 前言 软件环境 Openstack 简介 Openstack 架构 Openstack Install Overview 创建Node虚拟机 环境准备 基础设置 Install OpenS ...
- Mysql 生成随机数字
其实思路很简单,利用MySQL现有的函数,然后进行加工处理,达到预期的结果.可以用到的MySQL函数为rand() ,以及 round() 函数. 具体为:select round(rand()*10 ...
- zabbix--ODBC 监控mysql
zabbix ODBC 数据库监控ODBC 是 C 语言开发的.用于访问数据库的中间件接口.zabbix 支持查询任何 ODBC 支持的数据库.zabbix 通过调用ODBC 来获取数据库的数据以及数 ...
- sudo: unable to resolve host 枝桠
Ubuntu环境, 主机名字叫枝桠(机器的hostname), 每次执行sudo 就出现这个警告讯息: 虽然sudo 还是可以正常执行, 所以就直接从/etc/hosts 设定, 让枝桠(hostna ...
- MQ入门介绍
MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法.应用程序通过写和检索出入列队的针对应用程序的数据(消息)来通信,而无需专用连接来链接它们.消息传递指的是程序 ...
- C语言各种进制输出
#include<stdio.h> int main() { ; float f = 12.0; printf("十进制输出:%d\n", number); print ...
- shell只读变量
- EXCEL数据计算不准确的问题
今天,某部门的excel的数值计算,总是出现错误.如下图 ,我们的46那一栏是有前面8*6得出来的,但是结果却显示46,明明应该是48才对,然后再往上追,8是有前面的337-329得出来的,337是有 ...
- PHP水仙花数的实现
php水仙花数是什么? 水仙花数是指一个 n 位数 ( n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身.(例如:1^3 + 5^3 + 3^3 = 153)三位的水仙花数共有4个:153,3 ...