一个jquery的图片下拉列表 ddSlick
【ddSlick】http://designwithpc.com/Plugins/ddSlick
How to use with JSON data
Include the plugin javascript file along with jquery:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://dl.dropbox.com/u/40036711/Scripts/ddslick.js"></script>- Create an empty placeholder for the custom drop down: eg:
<divid="myDropdown"></div>
- Get the drop down options (JSON Data) to be binded to plugin:
//Dropdown plugin data
var ddData = [
{
text: "Facebook",
value: 1,
selected: false,
description: "Description with Facebook",
imageSrc: "http://dl.dropbox.com/u/40036711/Images/facebook-icon-32.png"
},
{
text: "Twitter",
value: 2,
selected: false,
description: "Description with Twitter",
imageSrc: "http://dl.dropbox.com/u/40036711/Images/twitter-icon-32.png"
},
{
text: "LinkedIn",
value: 3,
selected: true,
description: "Description with LinkedIn",
imageSrc: "http://dl.dropbox.com/u/40036711/Images/linkedin-icon-32.png"
},
{
text: "Foursquare",
value: 4,
selected: false,
description: "Description with Foursquare",
imageSrc: "http://dl.dropbox.com/u/40036711/Images/foursquare-icon-32.png"
}
]; Attach plugin to this placeholder like:
$('#myDropdown').ddslick({
data:ddData,
width:300,
selectText:"Select your preferred social network",
imagePosition:"right",
onSelected:function(selectedData){//callback function: do something with selectedData;}});Note: Use onSelected callback function to do something after the drop down option is selected. The selectedData will contain the selected text, value, description, imageSrc.
How to use with HTML <select> and <option>
- Include the plugin javascript file along with jquery:
<scripttype="text/javascript"src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<scripttype="text/javascript"src="http://dl.dropbox.com/u/40036711/Scripts/ddslick.js"></script> - Add HTML5 data attributes to your select elements: eg:
<selectid="demo-htmlselect">
<optionvalue="0"data-imagesrc="http://dl.dropbox.com/u/40036711/Images/facebook-icon-32.png"data-description="Description with Facebook">Facebook</option>
<optionvalue="1"data-imagesrc="http://dl.dropbox.com/u/40036711/Images/twitter-icon-32.png"data-description="Description with Twitter">Twitter</option>
<optionvalue="2"selected="selected"data-imagesrc="http://dl.dropbox.com/u/40036711/Images/linkedin-icon-32.png"data-description="Description with LinkedIn">LinkedIn</option>
<optionvalue="3"data-imagesrc="http://dl.dropbox.com/u/40036711/Images/foursquare-icon-32.png"data-description="Description with Foursquare">Foursquare</option>
</select> - Attach plugin to this HTML select element:
$('#myDropdown').ddslick({
onSelected:function(selectedData){//callback function: do something with selectedData;}});
Plugin Options:
- data default value '[]'
JSON data to populate drop down plugin options - width default value '260'
Width in px for the drop down plugin i.e. 400, or "400px". - height default value 'null'
Height in px for the drop down options i.e. 300, or "300px". The scroller will automatically
be added if options overflows the height. - background default value '#eee'
Background for your drop down. You can use the css shorthand notation for setting
backgrounds
i.e.background: #CCCCCC;orbackground: transparent url('your-background-image.jpg')
no-repeat 0 0 scroll - selectText default value 'Select...'
Set default text to display when no option is selected. - imagePosition default value 'left'
Set positioning of image in your drop down, left or right. See demo 5 above. - showSelectedHTML default value 'true'
Set what to be displayed as selected. Setting false will only display title. Setting
true displays title, description and image. - defaultSelectedIndex default value 'null'
Set the default index to be selected when initializing plugin. If not provided then
selectTextwill be displayed. See demo 4 above. - truncateDescription default value 'true'
Truncate the long description when selected. Options however display the full text.
The plugin still returns complete description on selection. See demo 6 above. - onSelected default value 'function () { }'
Callback function when an option is selected in the drop down. See demo 3 above. - keepJSONItemsOnTop default value 'false'
You can use both HTML select elements and JSON data to populate your drop down.
By default JSON items are added in drop down after the select options.
Plugin Methods:
- select
You may use plugin's select method like$('#demoSetSelected').ddslick('select',
{index: i });
to select a particular index. See demo 3 above. - select
You may use plugin's open method like$('#demoSetSelected').ddslick('open');
to open drop down options. - close
You may use plugin's close method like$('#demoSetSelected').ddslick('close');
to close drop down options. - destroy
You may use plugin's destroy method to restore to original element like$('#demoSetSelected').ddslick('destroy');
If you had selected an option with ddSlick, theselectedattribute
will be passed to the original HTML select, so you don't loose the selection. This
will also unbind any event handlers attached by plugin to this control. See demo
2 above.
一个jquery的图片下拉列表 ddSlick的更多相关文章
- PgwSlideshow-基于Jquery的图片轮播插件
0 PgwSlideshow简介 PgwSlideshow是一款基于Jquery的图片轮播插件,基本布局分为上下结构,上方为大图轮播区域,用户可自定义图片轮播切换的间隔时间,也可以通过单击左右方向按键 ...
- Image Wall - jQuery & CSS3 图片墙效果
今天我们要为您展示如何基于 jQuery 和 CSS3 创建一个整洁的图片墙效果.我们的想法是在页面上洒上一些大小不同的缩略图,并在当我们点击图片时候显示丝带,会显示一些描述,再次点击缩略图时,丝带将 ...
- jquery实现图片预加载
使用jquery实现图片预加载提高页面加载速度和用户体,本就为大家详细分析jquery图片预加载的实现原理. 什么时候使用图片预加载? 如果页面使用了很多不是最初加载便可见的图片,有必要进行预加载: ...
- 20+功能强大的jQuery/CSS3图片特效插件
以下是分享的20几个不错的图片特效插件,基于jQuery和CSS3. 1.jQuery图片下滑切换播放效果 这是一款基于jQuery的焦点图插件,这款焦点图的特点是有向下滑动的动画效果,滑到底部时,有 ...
- Jquery实现图片的预加载与延时加载
有很多项目经常会需要判断图片加载完成后执行相应的操作,或者需要图片延迟加载,网上虽然已经有很不错的插件,但要为这些效果还得单独加载一个插件的话总感觉有点不舒服,干脆自己写了个方法: 1 2 3 4 5 ...
- 18款 非常实用 jquery幻灯片图片切换
1.jquery图片滚动仿QQ商城带左右按钮控制焦点图片切换滚动 jquery图片特效制作仿腾讯QQ商城首页banner焦点图片轮播切换效果,带索引按钮控制和左右按钮控制图片切换. 查看演示>& ...
- jquery实现图片切换和js实现图片切换
jquery实现图片切换: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http ...
- 超酷的jQuery百叶窗图片滑块实现教程
原文:超酷的jQuery百叶窗图片滑块实现教程 今天我们要来分享一款基于jQuery的百叶窗焦点图插件,也可以说是图片滑块插件.这种jQuery焦点图插件的应用非常广泛,在早些年前,我们需要用flas ...
- jQuery百叶窗图片滑块
超酷的jQuery百叶窗图片滑块实现教程 今天我们要来分享一款基于jQuery的百叶窗焦点图插件,也可以说是图片滑块插件.这种jQuery焦点图插件的应用非常广泛,在早些年前,我们需要用flash ...
随机推荐
- POJ_3111_K_Best_(二分,最大化平均值)
描述 http://poj.org/problem?id=3111 n个珠宝,第i个有价值v[i]和重量w[i],要从总选k个,使得这k个的(价值之和)/(重量之和)即平均价值最大,输出选中的珠宝编号 ...
- Unable to Rebuild JIRA Index
Symptoms Accessing certain JIRA pages result in: SEVERE: Internal server error com.atlassian.jira.is ...
- Android 全屏显示-隐藏Navigation Bar
Sumsung Galaxy Nexus 屏幕分辨率为 1280X 720,但通常的应用都会显示Navigation Bar(Back 键,Home 键等),如下图所示: 但我注意到Youtube应用 ...
- (转载)Total Commander 常用快捷键(并附快捷键大全)
(转载)http://blog.chinaunix.net/uid-532511-id-3051990.html Total Commander 常用快捷键 喜欢用Total Commander的人, ...
- ASP.NET MVC利用PagedList分页(二)PagedList+Ajax+JsRender
(原文) 昨天在ASP.NET MVC利用PagedList分页(一)的 最后一节提到,一个好的用户体验绝对不可能是点击下一页后刷新页面,所以今天来说说利用Ajax+PagedList实现无刷新(个人 ...
- AIX项目总结_oracle_sqlloader_01
近来一直在忙AIX的移行项目,但也因自己小小偷懒,所以到现在才开始记录.接下来,言归正传. 这个项目中,学习中了shell相关知识,从基本的语法命令(定义变量.特殊变量使用.循环控制.方法调用等)到l ...
- 【leetcode】编辑距离
dp方程“ 1.初始化:dp[0][i]=i; dp[j][0]=j; 2.dp[i][j]= dp[i-1][j-1](相等) dp[i-1][j]+1 ,,dp[i][j-1]+1 ...
- Linux方向职业规划
Linux方向职业分析 引言: 据了解,Linux普通网络管理人员的月薪大约5000元左右,负责编程的Linux软件工程师月薪大约在8000元到12000元之间,Linux嵌入式软件开发人员的月薪大约 ...
- HTC仅限拨打紧急电话
问题描述: 我手上有台 HTC One V 没碰没撞,突然打不出电话,信号上显示一个叉,屏幕上显示“仅限拨打紧急电话” 解决办法:经百度,原来很多HTC机子都有这种情况,幸好不是硬件坏了,只需按以下步 ...
- 在Jersey中如何处理泛型集合
Jersey是一个标准的Restful Web service框架,可以方便的实现Restful的Server端和客户端. 本文主要介绍使用Jersey客户端时如何将Json格式的数组转换成java的 ...