引入部分:
<link rel="stylesheet" type="text/css" href="themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="themes/icon.css"/>
<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="locale/easyui-lang-zh_CN.js" type="text/javascript" charset="utf-8"></script>
推荐学习网站:http://www.jeasyui.net/plugins/
accordion:
<!DOCTYPE html>
<html>
<head>
<meta 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 src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$('#accordion').accordion({
width:300,
height:200
})
$("#accordion").accordion('add',{
title:'accordion1',
content:'accordion1 content',
selected:false
})
$("#accordion").accordion('add',{
title:'accordion2',
content:'accordion2 content',
selected:true
})
$("#accordion").accordion('add',{
title:'accordion3',
content:'accordion3 content',
selected:false
})
})
</script>
</head>
<body>
<div id="accordion">
</div>
</body>
</html>
datagrid:
<!DOCTYPE html>
<html>
<head>
<meta 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 src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="locale/easyui-lang-zh_CN.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
//把json数据获取出来
var data;
$.ajax({
type:"get",
url:"data.json",
async:true,
success:function(d){
data=d;
$('#datagrid').datagrid({
title:'学员信息',
sortOrder:'asc',
height:300,
width:300,
pagination:true,
pageSize:5,
aligh:'center',
remoteSort:false,
pageList:[5,10,15,20],
tools:[{
iconCls:'icon-add',
handler:function(){
$("#datagrid").datagrid('appendRow',{
id:21,
name:'蜡笔小新',
score:43
})
}
},{
iconCls:'icon-remove',
handler:function(){
$("#datagrid").datagrid('deleteRow',{
})
}
}],
columns:[[{
title:'学生编号',
field:'id',
width:100,
sortable:true
},{
title:'学员姓名',
field:'name',
width:100,
sortable:true
},{
title:'学生成绩',
field:'score',
width:100,
sortable:true
}]],
data:{
total:data.length,
rows:data.slice(0,5)
}
})
var pager=$('#datagrid').datagrid('getPager');
pager.pagination({
onSelectPage:function(pageNumber,pageSize){
//alert(pageNumber);
$('#datagrid').datagrid('loadData',{
total:data.length,
rows:data.slice((pageNumber-1)*pageSize,pageNumber*pageSize)
})
}
})
}
})
})
</script>
</head>
<body>
<table id="datagrid">
</table>
</body>
</html>
dialog:
<!DOCTYPE html>
<html>
<head>
<meta 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 src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$('#dialog').dialog({
title:'对话框',
width:300,
height:200,
resizable:true,
collapsible:true,
tools:[{
iconCls:'icon-add',
handler:function(){
alert('点击了添加');
}
},{
iconCls:'icon-clear',
handler:function(){
alert('点击了删除');
}
}],
toolbar:[{
iconCls:'icon-add',
handler:function(){
alert('添加');
},
text:'添加'
},{
iconCls:'icon-clear',
handler:function(){
alert('取消');
},
text:'取消'
}],
buttons:[{
iconCls:'icon-save',
handler:function(){
alert('保存');
},
text:'保存'
}],
})
})
</script>
</head>
<body>
<div id="dialog">
</div>
</body>
</html>
draggable:
<!DOCTYPE html>
<html>
<head>
<meta 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 src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$('#d1').draggable({
handle:'#d2',
onDrag:function(){
$(this).css('background-color','green');
},
onStopDrag:function(){
$(this).css('background-color','white');
}
})
alert($('#d1').draggable('options'));
})
</script>
</head>
<body>
<div id="d1" style="width: 200px;height: 200px;border: 1px solid red;">
<div id="d2" style="width: 100px;height: 100px;background-color: orange;">
</div>
</div>
</body>
</html>
messager:
<!DOCTYPE html>
<html>
<head>
<meta 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 src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$.messager.show({
title:'我的消息',
msg:'消息将在5秒后关闭。',
timeout:5000,
showType:'slide',
showspeed:3000
})
$.messager.alert('消息提醒','您有一条消息','warning')
})
</script>
</head>
<body>
</body>
</html>
panel:
DOCTYPE html>
<html>
<head>
<meta 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 src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$('#panel').panel({
title:'面板标题',
width:300,
height:200,
top:100,
style:{
position:'relative',
margin:'0px auto'
},
iconCls:'icon-save',
minimizable:true,
maximizable:true,
collapsible:true,
closable:true,
border:false,
content:'hello easyUI',
href:'file.txt',
tools:[{
iconCls:'icon-add',
handler:function(){
alert('点击了添加');
}
},{
iconCls:'icon-clear',
handler:function(){
alert('点击了删除');
}
}],
extractor:function(data){
var list=data.split(',');
var str='';
$(list).each(function(index){
str+=list[index];
})
return str;
}
})
})
</script>
</head>
<body>
<div id="panel">
面板区域显示的内容
</div>
</body>
</html>
progressbar:
<!DOCTYPE html>
<html>
<head>
<meta 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 src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$('#pro').progressbar({
width:400,
height:30,
value:0,
text:'进度{value}%',
onChange:function(n,o){
if(n==100){
alert("加载完毕");
}
}
})
setInterval(function(){
$("#pro").progressbar('setValue',$("#pro").progressbar('getValue')+1);
},100)
})
</script>
</head>
<body>
<div id="pro"style="margin: 0px auto;">
</div>
</body>
</html>
searchbox:
<!DOCTYPE html>
<html>
<head>
<meta 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 src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$('input').searchbox({
width:400,
height:30,
prompt:'请输入搜索内容',
searcher:function(){
alert($(this).searchbox('getValue'));
},
menu:'#mm'
})
})
</script>
</head>
<body>
<input type="text" name="" id="" value="" />
<div id="mm" style="width:150px">
<div data-options="name:'item1'">Search Item1</div>
<div data-options="name:'item2',selected:true">Search Item2</div>
<div data-options="name:'item3'">Search Item3</div>
</div>
</body>
</html>
switchbutton:
<!DOCTYPE html>
<html>
<head>
<meta 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 src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$('#a1').switchbutton({
width:100,
height:20
})
})
</script>
</head>
<body>
<div id="a1">
</div>
</body>
</html>
tabs:
<!DOCTYPE html>
<html>
<head>
<meta 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 src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$('#tabs').tabs({
width:500,
height:200,
tools:[{
iconCls:'icon-add',
handler:function(){
$("#tab").tabs('update',{
tab:$("#tab").tabs('getTab','tab2'),
options:{
title:'newtab1',
content:'新内容'
}
})
}
},{
iconCls:'icon-save',
handler:function(){
alert('保存')
}
}]
})
$('#tabs').tabs('add',{
title:'New Tab',
content:'Tab Body',
closable:false,
})
$('#tabs').tabs('add',{
title:'New Tab',
content:'Tab Body',
closable:true,
})
})
</script>
</head>
<body>
<div id="tabs">
</div>
</body>
</html>
tooltip:
<!DOCTYPE html>
<html>
<head>
<meta 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 src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$('#a1').tooltip({
content:'今天是星期三'
})
})
</script>
</head>
<body>
<a id="a1">提示框</a>
</body>
</html>
validatebox:
<!DOCTYPE html>
<html>
<head>
<meta 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 src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="locale/easyui-lang-zh_CN.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$.extend($.fn.validatebox.defaults.rules, {
minLength: {
validator: function(value, param){
return value.length >= param[0];
},
message: 'Please enter at least {0} characters.'
}
});
$(function(){
$("#email").validatebox({
required:true,
//validType:['email','length[0,20]']
validType:'minLength[10]'
})
})
</script>
</head>
<body>
用户名(邮箱)<input id="email" />
</body>
</html>
window:
<!DOCTYPE html>
<html>
<head>
<meta 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 src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$('#d1').window({
title:'这是一个窗口',
width:300,
height:200,
modal:false,
})
})
</script>
</head>
<body>
<div id="d1">
</div>
</body>
</html>