08-EasyUI尚硅谷-combo

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>Combo</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.2.6/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.2.6/themes/icon.css">
<script type="text/javascript" src="js/jquery-easyui-1.2.6/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery-easyui-1.2.6/jquery.easyui.min.js"></script>
<script type="text/javascript" src="js/jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js"></script>

<script type="text/javascript">
	$(function() {
		$("#myCombo").combo({
			required: true,
			editable: false,
			width: 255
		});
		$("#content").appendTo($("#myCombo").combo("panel"));	// 把下拉框的内容都添加到combo
		$("#content img").click(function() {					// 选择一项时触发
			var v = $(this).attr("value");						// 取文本
			var s = $(this).attr("text")						// 取input的文本值
			$("#myCombo").combo("setValue", v).combo("setText", s).combo("hidePanel");	// 设置combo的值和文本值,最后关闭
		});
	});
</script>
</head>

<body>
	<!-- combo -->
	<select id="myCombo"></select>
	<!-- 添加到combo中的内容 -->
	<div id="content">
		<div style="color:#99BBE8;background:#fafafa;padding:5px;font-size: 15px;">Select a car</div>
		<div>
			<img src="images/001.jpg" value="001.jpg" text="图片1">
		</div>
		<div>
			<img src="images/002.jpg" value="002.jpg" text="图片2">
		</div>
		<div>
			<img src="images/003.jpg" value="003.jpg" text="图片3">
		</div>
		<div>
			<img src="images/004.jpg" value="004.jpg" text="图片4">
		</div>
		<div>
			<img src="images/005.jpg" value="005.jpg" text="图片5">
		</div>
	</div>
</body>
</html>

 效果:

      

 

posted @ 2017-07-31 17:51  半生戎马,共话桑麻、  阅读(89)  评论(0)    收藏  举报
levels of contents