EasyUI中Accordion使用的代碼實例

 

<!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>
function select(){
$("#aa").accordion('select','Title1');//選擇title爲Title1的panel
}

var index=1;

//添加panel
function add(){
$('#aa').accordion('add',{
title:'New Title'+index,
content:'New Content'+index,
iconCls:'icon-save',
selected:false
});
index++;
}

//刪除功能
function remove(){
var panel = $('#aa').accordion('getSelected');//獲取當前選中的panel
var panelIndex=$("#aa").accordion('getPanelIndex',panel);//獲取當前選擇的panel的下標
$('#aa').accordion('remove',panelIndex); //根據下標刪除當前選中的panel
}
</script>
</head>

<body>
<div>點擊下邊按鈕測試功能</div>

<div style="margin: 10px 0;">
<a href="#" class="easyui-linkbutton" οnclick="select()">Select</a>
<a href="#" class="easyui-linkbutton" οnclick="add()">Add</a>
<a href="#" class="easyui-linkbutton" οnclick="remove()">Remove</a>
</div>

<div id="aa" class="easyui-accordion" style="width:500px;height:300px;" data-options="border:true,animate:true,fit:false">

<div title="Title1" data-options="iconCls:'icon-save'" style="overflow:auto;padding:10px;">
<h3 style="color:#0099FF;">Accordion for jQuery</h3>
<p>Accordion is a part of easyui framework for jQuery.
It lets you define your accordion component on web page more easily.</p>
</div>
<div title="Title2" data-options="iconCls:'icon-reload',selected:true" style="padding:10px;">
content2
</div>
<div title="Title3">
content3
</div>
</div>

</body>
</html>

發佈了22 篇原創文章 · 獲贊 4 · 訪問量 31萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章