jQuery Dialog dialog box event usage example analysis_jquery
the example in this article describes the usage of jquery dialog dialog box events. share it with everyone for your reference, the details are as follows:
dialog dialog event
dialog application scenarios
the dialog box is the most commonly used and practical function.
1) static prompt dialog box, the content of the dialog box is fixed
2) dynamic prompt dialog box, the content of the dialog box changes according to the event source
3) mask dialog box, when the dialog box pops up, the background turns gray and is not selectable
you can easily achieve the above three effects using jquery ui's dialog component
the main features of the dialog component are that it can be dragged (draggable) and resized (resizable).
the use of the dialog dialog box is also very simple. after selecting an element, you can use ".dialog()" on the element to turn it into a dialog box, and modify each element of the dialog box by passing various options attribute classes. kind of behavior.
usually a dialog box is a div element:
<div id="divtip" title="自定义标题"> <p>弹出层</p> </div>
the following statement will generate a dialog box using the default options attribute.
jquery("#divtip").dialog();
after executing the above statement, the div element becomes a draggable and stretchable dialog box.
of course this is just the simplest application. let's use a complete example to quickly get started with the dialog box component.
use dialog control to implement three specific pop-up boxes.
one is a static pop-up layer, that is, the content of the pop-up layer is fixed.
one is a dynamic pop-up layer, that is, the content of the pop-up layer varies according to the triggerer of the event.
the other is a common mask pop-up layer, that is, after the pop-up layer is displayed, elements on the page other than the pop-up layer cannot be operated.
first take a look at the html snippets of several elements on the page.
<!—demo 静态提示类弹出层—> <div class="ui-widget ui widget-contentui-corner-all" style="width:700px;padding:5px"> <h3 id="demo-共享同一个静态弹出层-弹出层内容固定">demo.共享同一个静态弹出层,弹出层内容固定:</h3> <div> <spanid="spanshowtip1">显示提示</span> <span id="spanshowtip2">显示提示</span> <spanid="spanshowtip3">显示提示</span> <span id="spanshowtip4">显示提示</span> </div> <br/> <br/> <!—demo动态显示类弹出层--> <div class="ui-widget ui-widget-contentui-corner-all" style="width:700px; padding:5px"> <h3 id="demo-每个弹出层内容不同-弹出层内容存在事件源的元素属性中">demo.每个弹出层内容不同,弹出层内容存在事件源的元素属性中:</h3> <div> <spanid="spanshowdatatip1" data="颜色是红色">红色</span> <span id="spanshowdatatip2" data="颜色是绿色">绿色</span> </div> </div> <br /> <br /> <!—demo.遮罩类弹出层--> <div class="ui-widget ui-widget-contentui-corner-all" style="width:700px;padding:5px"> <h3 id="demo-弹出iframe">demo.弹出iframe</h3> <div> <inputtype="button" id="bunshowiframe" name=" bunshowiframe" value="显示弹出层" /> </div> </div>
the element displayed on the element page is used to trigger the event of displaying the popup layer.
the html code of the pop-up layer is as follows:
<!—提示类弹出层—> <div id="divtip" title="自定义标题"> <p>弹出层</p> </div> <!—遮罩类弹出层—> <div id="diviframe" title="iframe 弹出层" style="text-align:center"> <iframesrc="http://www.hbcsdn.tk" width="480px"height="250px" frameborder="0"></iframe> </div>
the pop-up layer is a div element. it will be shown or hidden as needed.
with the html elements ready, the next step is to apply the jquery ui dialog control. first, in initializedom, get the page elements that need to be manipulated later.
initializeDom:function(){//初始化DOM this.$spanShowTip=$("span[id^=spanShowTip]"); this.$spanShowDataTip=$("span[id^=spanShowDataTip]"); this.$btnShowIframe=$("#btnShowIframe"); this.$divTip=$("#divTip"); tis.$divIframe=$("#divIframe"); }
readers who are interested in more jquery related content can check out the special topics on this site: "jquery switching special effects and techniques summary", "jquery drag effects and techniques summary", "jquery extension skills summary", "jquery common classic special effects summary", "jquery animation and special effects usage summary", "jquery selector usage summary 》and《jquery common plug-ins and usage summary》
i hope this article will be helpful to everyone in jquery programming.

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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:

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

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
