Home >Web Front-end >JS Tutorial >Easily learn the jQuery plug-in EasyUI EasyUI to create menus and buttons_jquery

Easily learn the jQuery plug-in EasyUI EasyUI to create menus and buttons_jquery

WBOY
WBOYOriginal
2016-05-16 15:28:451186browse

1. Create a simple menu with EasyUI

Menu is defined in some DIV tags, as shown below:

<div id="mm" class="easyui-menu" style="width:120px;">
 <div onclick="javascript:alert('new')">New</div>
 <div>
 <span>Open</span>
 <div style="width:150px;">
 <div><b>Word</b></div>
 <div>Excel</div>
 <div>PowerPoint</div>
 </div>
 </div>
 <div icon="icon-save">Save</div>
 <div class="menu-sep"></div>
 <div>Exit</div>
</div>

When the menu is created, it will not be displayed. Call the 'show' method to display it or the 'hide' method to hide it:

$('#mm').menu('show', {
 left: 200,
 top: 100
});

2. EasyUI creation button
1. EasyUI creates a link button (Link Button)
Typically, buttons are created using the bb9345e55eb71822850ff156dfde57c8 element, while link buttons (Link Buttons) are created using the 3499910bf9dac5ae3c52d5ede7383485 element. So actually a link button (Link Button) is an 3499910bf9dac5ae3c52d5ede7383485 element displayed as a button style.

To create a Link Button, all you need to do is add a class attribute called 'easyui-linkbutton' to the 3499910bf9dac5ae3c52d5ede7383485 element:

<div style="padding:5px;background:#fafafa;width:500px;border:1px solid #ccc">
 <a href="#" class="easyui-linkbutton" iconCls="icon-cancel">Cancel</a>
 <a href="#" class="easyui-linkbutton" iconCls="icon-reload">Refresh</a>
 <a href="#" class="easyui-linkbutton" iconCls="icon-search">Query</a>
 <a href="#" class="easyui-linkbutton">text button</a>
 <a href="#" class="easyui-linkbutton" iconCls="icon-print">Print</a>
</div>
 
<div style="padding:5px;background:#fafafa;width:500px;border:1px solid #ccc">
 <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-cancel">Cancel</a>
 <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-reload">Refresh</a>
 <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-search">Query</a>
 <a href="#" class="easyui-linkbutton" plain="true">text button</a>
 <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-print">Print</a>
 <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-help"></a>
 <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-save"></a>
 <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-back"></a>
</div>

As you can see, the iconCls property is a CSS class style for icon that displays an icon image on the button.
Sometimes you need to disable a Link Button or enable it. The following code demonstrates how to disable a Link Button:
$(selector).linkbutton('disable'); // call the 'disable' method
2. EasyUI creates menu button (Menu Button)
Menu Button
contains a button and a menu component. When you click or move the mouse over the button, a corresponding menu will be displayed.

In order to define a Menu Button, you should define a Link Button and a menu. Here is an example:

<div style="background:#fafafa;padding:5px;width:200px;border:1px solid #ccc">
 <a href="#" class="easyui-menubutton" menu="#mm1" iconCls="icon-edit">Edit</a>
 <a href="#" class="easyui-menubutton" menu="#mm2" iconCls="icon-help">Help</a>
</div>
<div id="mm1" style="width:150px;">
 <div iconCls="icon-undo">Undo</div>
 <div iconCls="icon-redo">Redo</div>
 <div class="menu-sep"></div>
 <div>Cut</div>
 <div>Copy</div>
 <div>Paste</div>
 <div class="menu-sep"></div>
 <div iconCls="icon-remove">Delete</div>
 <div>Select All</div>
</div>
<div id="mm2" style="width:100px;">
 <div>Help</div>
 <div>Update</div>
 <div>About</div>
</div>

Now that a Menu Button has been defined, you do not need to write any javascript code.
3. EasyUI creates a split button (Split Button)

Split Button Contains a Link Button and a Menu. When the user clicks or hovers the mouse over the down arrow area, a corresponding menu will be displayed. This example demonstrates how to create and use a Split Button.

We create a Split Button and a Link Button:

<div style="border:1px solid #ccc;background:#fafafa;padding:5px;width:120px;">
 <a href="#" class="easyui-splitbutton" menu="#mm" iconCls="icon-edit">Edit</a>
 <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-help"></a>
</div>
<div id="mm" style="width:150px;">
 <div iconCls="icon-undo">Undo</div>
 <div iconCls="icon-redo">Redo</div>
 <div class="menu-sep"></div>
 <div>Cut</div>
 <div>Copy</div>
 <div>Paste</div>
 <div class="menu-sep"></div>
 <div>
 <span>Open</span>
 <div style="width:150px;">
 <div>Firefox</div>
 <div>Internet Explorer</div>
 <div class="menu-sep"></div>
 <div>Select Program...</div>
 </div>
 </div>
 <div iconCls="icon-remove">Delete</div>
 <div>Select All</div>
</div>

Now that a Split Button has been defined, you don’t need to write any javascript code.

The above is the entire content of this article, I hope it will be helpful to everyone’s study.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn