我想在不同的按鈕點擊時彈出不同的窗體。我爲此使用此代碼。但所有按鈕點擊顯示第一個內容表單。它如何解決? 代碼多個元素的Javascript
<a href="#" class="button">Click 1</a>
<div id="modal">
<div id="heading">Content form 1</div>
</div>
<a href="#" class="button">Click 2</a>
<div id="modal">
<div id="heading">Content form 2</div>
</div>
<!--jQuery-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/jquery.reveal.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.button').click(function (e) { // Button which will activate our modal
$('#modal').reveal({ // The item which will be opened with reveal
animation: 'fade', // fade, fadeAndPop, none
animationspeed: 600, // how fast animtions are
closeonbackgroundclick: true, // if you click background will modal close?
dismissmodalclass: 'close' // the class of a button or element that will close an open modal
});
return false;
});
});
</script>
ID必須是唯一的。你需要改變ID,也許你''(this).next('。modal')'而不是.. – Ohgodwhy 2013-03-13 04:42:13
謝謝..它工作正常 – Aneesh 2013-03-13 04:45:46