Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript [HELP] Simple JS onClick Toggle Re: [HELP] Simple JS onClick Toggle

#55570
jamygolden
Member

Change

#scroll_box {
background: -moz-linear-gradient(#EEEEEE, #CCCCCC) repeat scroll 0 0 transparent;
border: medium none;
border-radius: 8px 8px 8px 8px;
box-shadow: 0 0 10px #222222;
color: #333333;
font-family: AllerBold;
height: auto;
margin-left: -200px;
margin-top: -292px;
padding: 10px 10px 10px 60px;
position: fixed;
text-decoration: none;
width: auto;
z-index: 1337;
}

to this:

#scroll_box {
background: -moz-linear-gradient(#EEEEEE, #CCCCCC) repeat scroll 0 0 transparent;
border: medium none;
border-radius: 8px 8px 8px 8px;
box-shadow: 0 0 10px #222222;
color: #333333;
font-family: AllerBold;
height: auto;
left: -45px;
padding: 10px 10px 10px 60px;
position: fixed;
text-decoration: none;
top: 220px;
width: auto;
z-index: 1337;
}

Basically I’ve removed margin and added the ‘top’ and ‘left’ properties. It didn’t, however, seem to open when I clicked on it.

As for it not opening when you click on it, that’s because the events are loaded in the DOM and afterwards you bring in the elements. Therefore they are not being effected by the javascript.

Change this:

$("#sidtgl a").click(function(){
$("#sidtgl").slideToggle("slow");
$(this).toggleClass("active");
});

to this:

$("#main-content").delegate("#sidtgl a", "click", function(){
$("#sidtgl").slideToggle("slow");
$(this).toggleClass("active");
});

If all goes well it should work.