- <!DOCTYPE>
- <html>
- <head>
- <title>jQueryOpenDIV</title>
- <script src1="http://code.jquery.com/jquery-1.7.2.min.js"></script>
- <style type="text/CSS">
- *{margin:0;padding:0;color:#FFF}
- #after_open{width:250px;height:150px;cursor:pointer;line-height:150px;display:none;background:#d24726;position:absolute;z-index:1;text-align:center}
- #open{ margin:0 auto;width:250px;height:50px;line-height:50px;background:#1d1d1d;cursor:pointer;text-align:center}
- </style>
- <script type="text/javascript">
- $(document).ready(function()
- {
- $("#open").click(function(event)
- {
- var offset = $(event.target).offset();
- $("#after_open").css({ top: offset.top + $(event.target).height() + "px", left: offset.left }).show();
- });
- $("#after_open").click(function(event) { $("#after_open").hide()});
- });
- </script>
- </head>
- <body>
- <div id="open">
- Click
- </div>
- <div id="after_open">
- Close
- </div>
- </body>
- </html>
- //该片段来自于http://www.codesnippet.cn/detail/300720134885.html
来源: http://www.codesnippet.cn/detail/300720134885.html