Jquery ThickBox的使用怎样做呢一样的,给添加链接加thickbox样式:!--br /br /Code highlighting prod
Jquery ThickBox的使用
怎样做呢一样的,给添加链接加thickbox样式:
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><a?href="add.shtml?width=300&height=250"?class="thickbox">新增</a>
前提是你得将要显示的页面(add.shtml)做好,然后指定你要显示的大小
编辑同样是一样:先将原信息提取出来,再让用户修改:

代码也一样:
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><a?href="edit.shtml?width=300&height=250&nid=item.nid"?class="thickbox">编辑</a>
4.能自己定位到需要用thickbox的元素,不使用样式,可以用函数,如:
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><div?id="PicList">
<a?href="Pic01.jpg"><img?src="Pic01s.jpg"?border="0"/></a>
<a?href="Pic02.jpg"><img?src="Pic01s.jpg"?border="0"/></a>
</div>
$(function()?{
tb_init("#PicList?a[img]");});
5.通过ajax加载的页面,thickbox样式会失效,解决办法:
只要在AJAX载入HTML并更新到页面后执行下以下代码:
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->tb_init('.thickbox');
6.自定义函数调用:
如点击缩图,要显示大图,缩略图URL只不过在大图URL的后缀前加了s:
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><div?id="PicList">
<img?src="Pic01s.jpg"?border="0"/>
<img?src="Pic01s.jpg"?border="0"/>
</div>
$(function()?{
$("#PicList?img").click(function()?{
tb_show("",this.src.substring(0,this.src.length-5)+'.jpg',false);
});});
另外,如果想用其它事件,还可以将click改成你想触发thickbox的事件。