我想用AJAX和.live(),所以我可以讓事情變得整潔。我想知道它是如何完成的,我已經提供了一個基本功能:在一個按鈕上單擊一個標籤放置在一個。但我需要使用live()才能在該圖像上使用lightbox。JQUERY住在AJAX
$(document).ready(function()
{
$("button").click(function()
{
$("div").load('test1.txt')
});
});
燈箱廣告:
$(function()
{
$('#gallery a').lightBox();
});
CSS:
<style type="text/css">
/* jQuery lightBox plugin - Gallery style */
#gallery
{
background-color: #444;
padding: 10px;
width: 520px;
}
#gallery ul
{
list-style: none;
}
#gallery ul li
{
display: inline;
}
#gallery ul img
{
border: 5px solid #3e3e3e;
border-width: 5px 5px 20px;
}
#gallery ul a:hover img
{
border: 5px solid #fff;
border-width: 5px 5px 20px;
color: #fff;
}
#gallery ul a:hover
{
color: #fff;
}
</style>
用法: 使用id =畫廊div標籤
HTML:
<link rel="stylesheet" type="text/css" href="../style-projects-jquery.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.lightbox-0.5.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.lightbox-0.5.css" media="screen" />
<h2 id="example">Example</h2>
<p>Click in the image and see the <strong>jQuery lightBox plugin</strong> in action.</p>
<div id="gallery">
<ul>
<li>
<a href="photos/image1.jpg" title="Utilize a flexibilidade dos seletores da jQuery e crie um grupo de imagens como desejar. $('#gallery').lightBox();">
<img src="photos/thumb_image1.jpg" width="72" height="72" alt="" />
</a>
</li>
</ul>
</div>
如果有人能幫助我改變。點擊()函數...
你可以發佈你的HTML嗎? – Kokos