Home >Web Front-end >JS Tutorial >How to use Jquery pop-up layer plug-in ThickBox_jquery
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
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:
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:
4. You can locate elements that require thickbox by yourself. Instead of using styles, you can use functions, such as:
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:
$(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!