【ddSlick】http://designwithpc.com/Plugins/ddSlick

How to use with JSON data

  1. 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>
  2. Create an empty placeholder for the custom drop down: eg:
    <divid="myDropdown"></div>
     
  3. 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"
    }
    ];
  4. 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>

  1. 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>
     
  2. 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>
     
  3. 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; or background: 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
    selectText will 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, the selected attribute
    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的更多相关文章

  1. PgwSlideshow-基于Jquery的图片轮播插件

    0 PgwSlideshow简介 PgwSlideshow是一款基于Jquery的图片轮播插件,基本布局分为上下结构,上方为大图轮播区域,用户可自定义图片轮播切换的间隔时间,也可以通过单击左右方向按键 ...

  2. Image Wall - jQuery & CSS3 图片墙效果

    今天我们要为您展示如何基于 jQuery 和 CSS3 创建一个整洁的图片墙效果.我们的想法是在页面上洒上一些大小不同的缩略图,并在当我们点击图片时候显示丝带,会显示一些描述,再次点击缩略图时,丝带将 ...

  3. jquery实现图片预加载

    使用jquery实现图片预加载提高页面加载速度和用户体,本就为大家详细分析jquery图片预加载的实现原理. 什么时候使用图片预加载? 如果页面使用了很多不是最初加载便可见的图片,有必要进行预加载: ...

  4. 20+功能强大的jQuery/CSS3图片特效插件

    以下是分享的20几个不错的图片特效插件,基于jQuery和CSS3. 1.jQuery图片下滑切换播放效果 这是一款基于jQuery的焦点图插件,这款焦点图的特点是有向下滑动的动画效果,滑到底部时,有 ...

  5. Jquery实现图片的预加载与延时加载

    有很多项目经常会需要判断图片加载完成后执行相应的操作,或者需要图片延迟加载,网上虽然已经有很不错的插件,但要为这些效果还得单独加载一个插件的话总感觉有点不舒服,干脆自己写了个方法: 1 2 3 4 5 ...

  6. 18款 非常实用 jquery幻灯片图片切换

    1.jquery图片滚动仿QQ商城带左右按钮控制焦点图片切换滚动 jquery图片特效制作仿腾讯QQ商城首页banner焦点图片轮播切换效果,带索引按钮控制和左右按钮控制图片切换. 查看演示>& ...

  7. jquery实现图片切换和js实现图片切换

    jquery实现图片切换: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http ...

  8. 超酷的jQuery百叶窗图片滑块实现教程

    原文:超酷的jQuery百叶窗图片滑块实现教程 今天我们要来分享一款基于jQuery的百叶窗焦点图插件,也可以说是图片滑块插件.这种jQuery焦点图插件的应用非常广泛,在早些年前,我们需要用flas ...

  9. jQuery百叶窗图片滑块

    超酷的jQuery百叶窗图片滑块实现教程   今天我们要来分享一款基于jQuery的百叶窗焦点图插件,也可以说是图片滑块插件.这种jQuery焦点图插件的应用非常广泛,在早些年前,我们需要用flash ...

随机推荐

  1. BZOJ_3670_[NOI2014]_动物园_(kmp)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=3670 对于一个字符串,求出num数组,其中num[i]表示前i个字符构成的字串中不相重合的相同 ...

  2. NopCommerce架构分析(转载)

    原文 一,NopCommerce架构分析之开篇 NopCommerce是.net开源项目中比较成熟的一款业务应用框架,也是电子商务系统中的典范.所以很想多学习一下里面的设计和实现方式. 二,NopCo ...

  3. vs2010 更新jQuery智能提示包

    vs2010 更新jQuery只能提示包时,可以直接在NuGet中更新 jquery-2.1.0-vsdoc.js jquery-2.1.0.js jquery-2.1.0.min.js jquery ...

  4. ldr指令总结

    LDR/STR字和无符号字节加载/存储 1,LDR Rd,[Rn]   2, LDR Rd,[Rn,Flexoffset] 3, LDR Rd,[Rn],Flexoffset 4, LDR Rd,la ...

  5. 机器学习-review-1 线性回归

    发现隔一段时间,忘记了好多知识点,这里认为重要的知识点记录下来,作为笔记,方便以后回顾. From “李航- 统计学习方法” 统计学习方法的三要素: 模型,策略, 算法 对于线性回归 -------- ...

  6. Linux趣谈

    要解释操作系统是如何工作的,首先可以用这几个关键字来简单地概括一下:冯诺依曼.堆栈机制和中断机制. 提到冯诺依曼很显然就是在说存储程序了,这大概是计算机能够运行最为基础的条件,属于基石级别的.它的基本 ...

  7. poj 2828 Buy Tickets【线段树单点更新】【逆序输入】

    Buy Tickets Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 16273   Accepted: 8098 Desc ...

  8. oracle Imp和exp以及导入常见的错误

    一 1) 数据库对象已经存在 一般情况, 导入数据前应该彻底删除目标数据下的表, 序列, 函数/过程,触发器等; 数据库对象已经存在, 按缺省的imp参数, 则会导入失败 如果用了参数ignore=y ...

  9. 探索AutoLayout的本质和解决一些问题

    最近频繁使用AutoLayout,记录下自己的一些发现和问题的解决(不是教程) 1.简介 Auto Layout 是苹果在 iOS 6中新引入的布局方式,旨在解决不同尺寸屏幕的适配问题. 屏幕适配工作 ...

  10. composer 常用命令

    composer list 列出所有可用的命令 composer init 初始化 composer.json文件(就不劳我们自己费力创建啦),会要求输入一些信息来描述我们当前的项目,还会要求输入依赖 ...