JavaScript UI design based on jQuery
jQuery UI is an open source JavaScript web user interface code library based on jQuery. It is a collection of user interface components officially launched by jquery to be used with jquery! Contains many interface operation functions.
Whether it is jQuery UI or jQuery's EasyUI framework can help you, making it easy for you to build your web page.
jQuery UI or easyui is a collection of user interface plugins based on jQuery.
Using jQuery UI or easyui you don't need to write a lot of JavaScript code, you usually define the user interface by writing some HTML markup.
jQuery UI or easyui is easy yet powerful.
When using jQuery UI or easyui, you need to add some js and css files to your page. Of course, you can also define the css you need.
jQuery UI and easyui are tools that we can use. They are packaged and written in different versions, so that we don’t have to consider browser compatibility when using them, and we don’t have to worry about writing. The most common problem of incompatibility between different browsers when creating a page can be used directly, which is a true "use doctrine".
The functions of the plug-ins provided by jQuery UI and easyui are different.
There are three major categories of functions provided by jQuery UI, including Interactions, Widgets, and Effects.
Interactions includes Draggable, Droppable, Resizable, Selectable, and Sortable functions for us to choose from.
Widgets class includes different functions such as Accordion, Datepicker, Dialog, Progressbar, Slider, and Tabs.
The Effects class includes functions such as Add Class, Remove Class, Animate, Effect, show, Switch Class, Toggle, and Toggle Class.
Each function will have different attributes and different effects. I will explain the usage of each function in detail later.
And easyui contains a total of 7 categories.
The first category is Base, which includes four aspects: EasyLoader, Draggable, Droppable, and Resizable.
The second category is Layout, which includes four aspects: Panel, Tabs, Accordion, and Layout.
The third category is Menu and Button, which contains the four effects of creating buttons: Menu, Link Button, Menu Button, and Split Button.
The fourth category is Form, including Form, ComboBox, ComboTree, NumberBox, ValidateBox, DateBox, and Calendar.
The fifth category is Window, including window, Dialog, and Message.
The sixth category is DataGrid and Tree, including Pagination, DataGrid, and Tree.
Let’s first take a look at the specific usage of each function of jQuery UI.
We start with Draggable in Interactions.
"EN-US">Draggable has many effects. Different parameters of the methods it gives can achieve different effects. It requires jquery-1.3.2.js, ui.core.js, These three js files are ui.draggable.js. The method it provides is draggable(), and it can achieve different effects by giving it different parameters.
Let’s take a look at the first effect (Default functionality) first. You can drag a DOM element with the mouse on the page within the range you can see. The code used is:
这段代码比之前的代码要复杂,所实现的效果也更多,它可以计算你共拖动了多少次DOM和你共拖动了多少距离。
它通过在draggable方法内增加的一个数组counts来存储开始和结束时的次数,和你一共拖动的距离。
我们再看第三个效果(Constrain movement),代码:
$(function() {
$("#draggable").draggable({ axis: 'y' });
$("#draggable2").draggable({ axis: 'x' });
$("#draggable3").draggable({ containment: '#containment-wrapper', scroll: false });
; Different parameters achieve different effects. The first method call allows the DOM to only move up and down, the second method call allows the DOM to only move left and right, the third method call allows the DOM to move only within the box specified for it, and the fourth method call allows the DOM to move only within the box specified for it. It can be moved outside the box, and the fifth method call allows the DOM to be moved only within its parent node. The fourth effect (Delay start), code: 20 }); ;The parameters it gives have certain restrictions, such as distance:20, which means you must drag more than 20px to have an effect, otherwise it will not let you drag, and delay is a delay , means that you have to wait until 1000ms before you can drag it. The fifth effect (Snap to element or grid) able" ).draggable({ snap: true }); snap: '.ui-widget-header', snapMode: 'outer' }); ).draggable({ grid: [80, 80] }); ); Let DOM be adsorbed on the edge of a large box, both inside and outside. The third parameter allows DOM to be adsorbed only on the outside of the box, but has no effect on the inside. The fourth parameter allows DOM to be moved only to 20,20. In places like multiples, the fifth parameter and the fourth parameter are the same, but the data given are different. The sixth effect (Auto-scroll)The first DOM can be dragged normally, and the second DOM will return to its original position after being dragged. The helper attribute is mentioned above, and the opacity attribute sets the transparency of the DOM. The third DOM will display a DIV of I'm a custom helper to you when you implement dragging. As for the next three DOMs, each time you drag a DOM, the dragged DOM will be on the outer layer of the other two DOMs, that is, on top. 🎙 }); $("#draggable2"). In these two DOMs, there is a p tag nested in each DIV. Each handle attribute indicates that the mouse can drag the DOM only when the mouse clicks on the P tag, and the second cancel indicates You have to click in a DIV that is not a P tag to drag the DOM. The tenth effect (Cursor style)The above code makes the ul and li elements in the page appear sortable while being dragged. The second introduction is "EN-US">droppable, which contains six effects, which require the use of "EN-US">jquery-1.3.2.js, "EN-US" ">ui.core.js, "EN-US">ui.droppable.js, "EN-US">ui.draggable.js are four js files.
Let’s look at the first one (Default functionality) first
$("#draggable" -highlight').find('p').html('Dropped!');
The above code indicates that when the DOM is dragged Move to the specified DOM, the DOM background color changes, and a class effect is added.
The second one (Accepted elements), code:
.draggable(); Class: 'ui-state-hover',
active ',
}); ) method, and gives hoverCalss, so that it will also produce an effect when it is dragged to the specified DOM and floated, and will produce an effect again when the mouse is released.
The third (Prevent propagation), code:
hoverClass: 'ui-state-active',
event, ui) {
$(this).addClass('ui-state-highlight').find('> p').html('Dropped!');
});
greedy: true, . ui-state-highlight').find('> p').html('Dropped!');
;/script>
First Give the first DOM a draggable effect, and then call the droppable() method on both the second large DOM and the third DOM. The difference is that the second method returns false when calling drop, and the third None is returned. The third DOM calls greedy:true at the beginning. They respectively indicate that when the first DIV is dragged to the second DIV of the same level, if it is dragged to the DIV of its same level, When it is up, only the outer DIV will have an effect. If you drag to the inner DIV, the entire DIV will have an effect, that is, including the outer DIV of the same level. After the third function is called, only the DIV you drag to Which layer of DIV, which layer of DIV produces the effect. $ ("#droppable").droppable({
$(this).addClass('ui-state-highlight') .find('p').html('Dropped!');
ggable2").draggable();
$("#droppable2"). droppable({
ui) {
').find('p').html('Dropped!');
This also makes two of the DOM You can drag the other two corresponding DOMs. This time the two corresponding DOMs call hoverCalss and activeClass respectively to produce different effects. They all behave differently when the mouse drags the DOM to float on it.
The fifth (Revert draggable position) code:
(Revert draggable position) code:
$("#droppable ").droppable({
event, ui) {
'ui-state-highlight').find('p').html('Dropped!');
>
Similarly, Give two of the DOMs draggable effects, and then drag the two DOMs to the specified DOM respectively. They gave different revert parameters when calling the draggable() method, allowing them to drag to the specified DOM to produce different effects. The first effect is that after dragging to the specified DOM, it returns to its original position. , and the specified DOM also produces corresponding effects. The second effect is that when it is dragged to the specified DOM, the specified DOM produces corresponding effects. When it is dragged out again, it returns to the position of the original DOM.
The sixth one (Simple photo manager), code:
trash
= $('#gallery'), $trash = $('#trash'); ).draggable({
: 'a.ui-icon',// clicking an icon won't initiate dragging
Containment: $('# demo-frame').length ? '#demo-frame' : 'document', // stick to demo-frame if present cursor: 'move'
// let the trash be droppable, accepting the gallery items
$trash.droppable({
accept: '#gallery > li',
activeClass: 'ui-state-highlight',
drop: function(ev, ui) {
deleteImage(ui.draggable);
}
});
// let the gallery be droppable as well, accepting items from the trash
$gallery.droppable({
accept: '#trash li',
activeClass: 'custom-state-active',
drop: function(ev, ui) {
recycleImage(ui.draggable);
}
});
// image deletion function
function deleteImage($item) {
$item.fadeOut(function() {
var $list = $('ul',$trash).length ? $('ul',$trash) : $('
$item.find('a.ui-icon-trash').remove();
$item.append(recycle_icon).appendTo($list).fadeIn(function() {
$item.animate({ width: '48px' }).find('img').animate({ height: '36px' });
});
});
}
// image recycle function
function recycleImage($item) {
$item.fadeOut(function() {
$item.find('a.ui-icon-refresh').remove();
$item.css('width','96px').append(trash_icon).find('img').css('height','72px').end().appendTo($gallery).fadeIn();
});
}
// image preview function, demonstrating the ui.dialog used as a modal window

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Detailed explanation of jQuery reference method: Quick start guide jQuery is a popular JavaScript library that is widely used in website development. It simplifies JavaScript programming and provides developers with rich functions and features. This article will introduce jQuery's reference method in detail and provide specific code examples to help readers get started quickly. Introducing jQuery First, we need to introduce the jQuery library into the HTML file. It can be introduced through a CDN link or downloaded

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

jQuery is a fast, small, feature-rich JavaScript library widely used in front-end development. Since its release in 2006, jQuery has become one of the tools of choice for many developers, but in practical applications, it also has some advantages and disadvantages. This article will deeply analyze the advantages and disadvantages of jQuery and illustrate it with specific code examples. Advantages: 1. Concise syntax jQuery's syntax design is concise and clear, which can greatly improve the readability and writing efficiency of the code. for example,

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute

jQuery is a popular JavaScript library that is widely used to handle DOM manipulation and event handling in web pages. In jQuery, the eq() method is used to select elements at a specified index position. The specific usage and application scenarios are as follows. In jQuery, the eq() method selects the element at a specified index position. Index positions start counting from 0, i.e. the index of the first element is 0, the index of the second element is 1, and so on. The syntax of the eq() method is as follows: $("s
