Home > Web Front-end > JS Tutorial > body text

How to use Jquery pop-up layer plug-in ThickBox_jquery

WBOY
Release: 2016-05-16 16:28:07
Original
1850 people have browsed it

Thickbox is a plug-in for jQuery. Its function is to pop up dialog boxes and web page boxes to make the user experience more pleasant. Here is a brief introduction to its usage.
Disclaimer: This is just a personal summary record.
Preparation work: You need three files: thickbox.js, thickbox.css, jquery.js, which can be downloaded from anywhere online

Specific use:

Step one: Introduce these three files to the page where you want to use thickbox

Copy code The code is as follows:




The second step: Generally simple use is to add styles to the label and Button: class=thickbox
There is also the thickbox function call: such as tb_init(), tb_show(); see below.

Several different uses:

1. Click to display the picture:


ok, that’s it
2. Click the button or link:

Copy code The code is as follows:


Show hidden modal content.


Instructions: Add "#TB_inline?height=300&width=400&" to the or button you want to use thickbox. #TB_inline is a fixed usage of thickbox. Height and width are the size parameters for displaying the pop-up dialog box. InlineId is For the label or component you want to display, modal is the choice between mode and non-modal. Of course, you can also accept many customized parameters
3. Generally, the page that is used more often in projects is the page that loads the form. For example, adding and editing are on the same list page. At this time, we can make both adding and editing into thickbox form, as shown below:

How to do it is the same, add thickbox style to the added link:

Add
The premise is that you have to prepare the page you want to display (add.shtml), and then specify the size you want to display
Editing is the same: extract the original information first, and then let the user modify it:

The same code:

Copy code The code is as follows:

4. You can locate elements that require thickbox by yourself. Instead of using styles, you can use functions, such as:

Copy code The code is as follows:




$(function() {
tb_init("#PicList a[img]");});

5. For pages loaded through ajax, the thickbox style will be invalid. Solution:
Just execute the following code after AJAX loads the HTML and updates it to the page:

tb_init('.thickbox');
6. Custom function call:
If you click on the thumbnail, to display the large image, the thumbnail URL just adds s:

before the suffix of the large image URL.

Copy code The code is as follows:




$(function() {
$("#PicList img").click(function() {
tb_show("",this.src.substring(0,this.src.length-5) '.jpg',false);
});});

In addition, if you want to use other events, you can also change click to the event you want to trigger the thickbox.

THICKBOX supports the following browsers:
Windows IE 6.0, Windows IE 7, Windows FF 2.0.0.6, Windows Opera 9.0, Macintosh Safari 2.0.4, Macintosh FF 2.0.0.6, Macintosh Opera 9.10... But according to my experience, IE6 still has some problems!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!