actions.html 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Accordion Actions - jQuery EasyUI Demo</title>
  6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
  7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
  8. <link rel="stylesheet" type="text/css" href="../demo.css">
  9. <script type="text/javascript" src="../../jquery.min.js"></script>
  10. <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
  11. </head>
  12. <body>
  13. <h2>Accordion Actions</h2>
  14. <p>Click the buttons below to add or remove accordion items.</p>
  15. <div style="margin:20px 0 10px 0;">
  16. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="selectPanel()">Select</a>
  17. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="addPanel()">Add</a>
  18. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="removePanel()">Remove</a>
  19. </div>
  20. <div id="aa" class="easyui-accordion" style="width:500px;height:300px;">
  21. <div title="About" data-options="iconCls:'icon-ok'" style="overflow:auto;padding:10px;">
  22. <h3 style="color:#0099FF;">Accordion for jQuery</h3>
  23. <p>Accordion is a part of easyui framework for jQuery. It lets you define your accordion component on web page more easily.</p>
  24. </div>
  25. </div>
  26. <script type="text/javascript">
  27. function selectPanel(){
  28. $.messager.prompt('Prompt','Please enter the panel title:',function(s){
  29. if (s){
  30. $('#aa').accordion('select',s);
  31. }
  32. });
  33. }
  34. var idx = 1;
  35. function addPanel(){
  36. $('#aa').accordion('add',{
  37. title:'Title'+idx,
  38. content:'<div style="padding:10px">Content'+idx+'</div>'
  39. });
  40. idx++;
  41. }
  42. function removePanel(){
  43. var pp = $('#aa').accordion('getSelected');
  44. if (pp){
  45. var index = $('#aa').accordion('getPanelIndex',pp);
  46. $('#aa').accordion('remove',index);
  47. }
  48. }
  49. </script>
  50. </body>
  51. </html>