开发者

Slide toggle jQuery, doesn't effect other page elements

I have a picture on the left side of my page, and a void link that when clicked will toggle open a container for other, external links. I need for the scroll of the web page to not be affected when the container is toggled open. Thanks in advance.

<!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" />

</head>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<script type="text/javascript" src="jquery.js">
</script>
<style type="text/css">
*, * focus {
    outline: none;
    margin: 0;
    padding: 0;
}

.container {
    width: 500px;
    float:right;
    margin: 0 auto;
}
h1 {
    font: 4em normal Georgia, 'Times New Roman', Times, serif;
    text-align:center;
    padding: 10px 0;
    color: #aaa;
}
h2.trigger {
    padding: 0 0 0 0;
    margin: 0 0 5px 0;

    height: 46px;
    line-height: 46px;
    width: 450px;
    font-size: 2em;
    font-weight: normal;
    float: right;
}
h2.trigger a {
    color: gray;
    text-decoration: none;
    display: block;
    float:right;
}
h2.trigger a:hover {
    color: #ccc;
}
h2.active {background-position: left bottom;}
.toggle_container {
    margin: 0 0 5px;
    padding: 0;
    border-top: 1px solid #d6d6d6;

    overflow: hidden;
    font-size: 1.2em;
    width: 350px;
    clear: both;
    float:right;
}
.toggle_container .block {
    padding: 5px;

}
</style>
<script type="text/javascript">
$(document).ready(function () {
$('#nav li').hover(
function () {
//show its submenu
$('ul', this).slideDown(250);
},
function () {
//hide its submenu
$('ul', this).slideUp(250);

}
);
$(".toggle_container").hide();

  开发者_StackOverflow  $("h2.trigger").click(function(){
        $(this).toggleClass("active").next().slideToggle("fast");
    });

});
</script>
<h2 class="trigger"><a href="#"> Popular Links</a></h2>
    <div class="toggle_container">
        <div class="block">
            <p>links</p>
            <p>more links</p>
        </div>
    </div>
    </div>

picture is here, wasn't allowed to post the code.


if i understand correctly, you don't want the browser to jump to the top of page? if so, instead of href="#" you can try putting href="javascript:;"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜