【发布时间】:2013-02-28 21:48:38
【问题描述】:
我想在不同的按钮点击时弹出不同的表单。我正在为此使用此代码。但所有按钮单击都显示第一个内容表单。它是如何解决的? 代码
<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').. -
谢谢.. 效果很好
标签: javascript jquery