EasyUI中包選擇按鈕的下拉列表的代碼實例

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>包含選擇按鈕的下拉列表(單選)</title>
<link rel="stylesheet" type="text/css" href="themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="themes/icon.css">
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="jquery.easyui.min.js"></script>
<script type="text/javascript">
$(function(){
$('#cc').combo({
required:true,
editable:false
});
//爲combo設置下拉列表值
$("#sp").appendTo($("#cc").combo('panel'));
//設置選擇項
$("#sp input").click(function(){
//獲取選中的值
var value=$(this).val();
//獲取下拉顯示值
var text=$(this).next("span").text();
//設置下拉選中值
$('#cc').combo('setValue', value).combo('setText', text).combo('hidePanel');
});

});
</script>
</head>

<body>
<h3>默認情況下的Combo</h3>
<select id="cc"></select>
<div id="sp">
<div style="color:#99BBE8;background:#fafafa;padding:5px;">Select a language</div>
<input type="radio" name="lang" value="01"><span>Java</span><br/>
<input type="radio" name="lang" value="02"><span>C#</span><br/>
<input type="radio" name="lang" value="03"><span>Ruby</span><br/>
<input type="radio" name="lang" value="04"><span>Basic</span><br/>
<input type="radio" name="lang" value="05"><span>Fortran</span>
</div>
</body>
</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章