---
title: "combo--2"
author: "youyang_java"
date: "2014-06-16T10:02:20Z"
tags: []
categories: ["Web前端"]
slug: "combo-2"
draft: false
lastmod: "2014-06-16T10:02:20Z"
id: 2080452
url: "https://youyang-java.iteye.com/blog/2080452"
---

![](http://dl2.iteye.com/upload/attachment/0098/1383/67420d65-70f1-386d-93f3-cbf5f6a7a8f0.png)  
 &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;  
&lt;html&gt;  
  &lt;head&gt;  
    &lt;title&gt;1.html&lt;/title&gt;  
   
    &lt;meta http-equiv="keywords" content="keyword1,keyword2,keyword3"&gt;  
    &lt;meta http-equiv="description" content="this is my page"&gt;  
    &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&gt;  
     
    &lt;!-- easyui的样式 --&gt;  
    &lt;link rel="stylesheet" type="text/css" href="../jslib/jquery-easyui-1.3.1/themes/default/easyui.css"&gt;  
    &lt;!-- 小图标的样式 --&gt;  
    &lt;link rel="stylesheet" type="text/css" href="../jslib/jquery-easyui-1.3.1/themes/icon.css"&gt;  
     
    &lt;script type="text/javascript" src="../jslib/jquery-easyui-1.3.1/jquery-1.8.0.min.js"&gt;&lt;/script&gt;  
    &lt;script type="text/javascript" src="../jslib/jquery-easyui-1.3.1/jquery.easyui.min.js"&gt;&lt;/script&gt;  
    &lt;script type="text/javascript" src="../jslib/jquery-easyui-1.3.1/locale/easyui-lang-zh\_CN.js"&gt;&lt;/script&gt;  
   
 &lt;script type="text/javascript"&gt;  
  $(function(){  
   $('#cc').combo({  
    width:170,  
    required:true,  
    editable:false,  
    panelWidth:170,  
    panelHeight:300,  
    value : '1',  
    onChange: function(newValue, oldValue){  
     alert("newValue="+newValue+",oldValue="+oldValue);  
    },  
    validType:'email'  
   });  
     
   //让输入框获取焦点  
   $('#cc').combo('textbox').focus();  
     
   $('#sp').appendTo($('#cc').combo('panel'));  
   $('#sp img').click(function(){  
    var v = $(this).attr("v");  
    var s = $(this).attr("t");  
    $('#cc').combo('setValue', v).combo('setText', s).combo('hidePanel');  
   });  
  });  
    
  var showPal = function(){  
   $('#cc').combo('showPanel');  
    
  }  
 &lt;/script&gt;  
   
  &lt;/head&gt;  
     
  &lt;body&gt;   
   &lt;select id="cc" style="width:150px"&gt;&lt;/select&gt;  
 &lt;div id="sp"&gt;  
  &lt;div style="color:#99BBE8;background:#fafafa;padding:5px;"&gt;请选择一个图片&lt;/div&gt;  
  &lt;div style="padding:10px"&gt;  
   &lt;img src="../style/images/dogs/puppy\_dogs\_01.png" v="1" t="1图片"&gt;&lt;br/&gt;  
   &lt;img src="../style/images/dogs/puppy\_dogs\_02.png" v="2" t="2图片"&gt;&lt;br/&gt;  
   &lt;img src="../style/images/dogs/puppy\_dogs\_03.png" v="3" t="3图片"&gt;&lt;br/&gt;  
   &lt;img src="../style/images/dogs/puppy\_dogs\_04.png" v="4" t="4图片"&gt;&lt;br/&gt;  
   &lt;img src="../style/images/dogs/puppy\_dogs\_05.png" v="5" t="5图片"&gt;&lt;br/&gt;  
   &lt;img src="../style/images/dogs/puppy\_dogs\_06.png" v="6" t="6图片"&gt;&lt;br/&gt;  
   &lt;img src="../style/images/dogs/puppy\_dogs\_07.png" v="7" t="7图片"&gt;&lt;br/&gt;  
  &lt;/div&gt;  
 &lt;/div&gt;  
 &lt;button onclick="showPal();"&gt;显示下拉列表&lt;/button&gt;  
 &lt;button onclick="$('#cc').combo('clear');"&gt;清空下拉列表&lt;/button&gt;   
  &lt;/body&gt;  
&lt;/html&gt;