Hello friends. What am I doing wrong, please?
This effect is well jsfiddle:
http://jsfiddle.net/EhJfn/49/
But in a full page does not work.
What am I doing wrong, please?
Full page:
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>button</title>
- <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
- <script>
- function noPropagate(event) {
- event.stopPropagation();
- }
- $('.btn').on('click').then(noPropagate)
- .siblings('.btn.active').click().end()
- .toggleClass('active')
- .next().slideToggle();
- $('.content').click(false);
- $(document).on('click ')
- .$('.content').slideUp()
- .$('.btn').removeClass('active');
- </script>
- <style type="text/css">
- .btn {
- font-size:24px;
- }
- #button1{
- margin-left:110px;
- }
- #button2{
- margin-left:100px;
- }
- .content {
- position: absolute;
- text-align: center;
- display: none;
- }
- #content1{
- height:200px;
- width:300px;
- background-color:#F0F;
- }
- #content2{
- height:200px;
- width:400px;
- margin-left:100px;
- background-color:#0F0;
- }
- .active {
- background-color:#D8D8D8;
- }
- .btn:hover {
- text-decoration: underline;
- background-color:#D8D8D8;
- }
- .active + .content {
- z-index: 2;
- }
- </style>
- </head>
- <body>
- <a class="btn" href="#" id="button1">Button1</a>
- <div class="content" id="content1">
- Content 1
- </div>
- <a class="btn" href="#" id="button2">Button2</a>
- <div class="content" id="content2">
- Content 2
- </div>
- </body>
- </html>