How can I add on Toggle Button Javascript slideup/slidedown?
3 posters
Page 1 of 1
How can I add on Toggle Button Javascript slideup/slidedown?
Hello,
How can I add on Toggle Button Javascript slideup/slidedown functions on this javascript and change a little bit the mainhead 's bar color to looks collapsed on collapsed category?
How can I add on Toggle Button Javascript slideup/slidedown functions on this javascript and change a little bit the mainhead 's bar color to looks collapsed on collapsed category?
- Code:
$(function(){$(".main .main-head").prepend('<span class="collapse" style="padding: 0px; float:right;width: 28px;height: 17px;overflow: hidden;cursor:pointer;"><img src="http://i73.servimg.com/u/f73/17/06/15/51/cat_mi11.png" alt="Close" /><img class="hide" src="http://i73.servimg.com/u/f73/17/06/15/51/cat_ma11.png" alt="Open" /></span>');$(".collapse").each(function(a){$(this).attr("id","collapse"+location.pathname+a);if(my_getcookie("collapse"+location.pathname+a)=="2"){$(this).children("img[alt='Close']").hide();$(this).children("img[alt='Open']").show();$(this).parent().next().hide()}});$(".collapse img[alt='Close']").click(function(){my_setcookie($(this).parent().attr("id"),1,2,0);$(this).hide().next().show();$(this).parent().parent().next().hide()});$(".collapse img[alt='Open']").click(function(){my_setcookie($(this).parent().attr("id"),0,2,0);$(this).hide().prev().show();$(this).parent().parent().next().show()})});
Re: How can I add on Toggle Button Javascript slideup/slidedown?
I'm not sure what you mean about the mainhead color, but you can change your script to the one below for the slide effect.
Basically you change hide() into slideUp() and show() into slideDown()
- Code:
$(function(){
$(".main .main-head").prepend('<span class="collapse" style="padding: 0px; float:right;width: 28px;height: 17px;overflow: hidden;cursor:pointer;"><img src="http://i73.servimg.com/u/f73/17/06/15/51/cat_mi11.png" alt="Close" /><img class="hide" src="http://i73.servimg.com/u/f73/17/06/15/51/cat_ma11.png" alt="Open" /></span>');
$(".collapse").each(function(a){
$(this).attr("id","collapse"+location.pathname+a);
if(my_getcookie("collapse"+location.pathname+a)=="2"){
$(this).children("img[alt='Close']").hide();
$(this).children("img[alt='Open']").show();
$(this).parent().next().hide()
}
});
$(".collapse img[alt='Close']").click(function(){
my_setcookie($(this).parent().attr("id"),1,2,0);
$(this).hide().next().show();
$(this).parent().parent().next().slideUp()
});
$(".collapse img[alt='Open']").click(function(){
my_setcookie($(this).parent().attr("id"),0,2,0);
$(this).hide().prev().show();
$(this).parent().parent().next().slideDown()
});
});
Basically you change hide() into slideUp() and show() into slideDown()
Re: How can I add on Toggle Button Javascript slideup/slidedown?
Thank you very much @An I setup and the slideup/slidedown functions it working perfectly the only problem is that not changes the opacity of the collapsed category 's header (main-head) keeps the original colors.
Re: How can I add on Toggle Button Javascript slideup/slidedown?
So you want it to become a different color when it's hidden? Find the two event handlers below.
Inside the first event handler (which is for [alt='Close']) add the statement below. It can be after or before any of the existing statements (e.g. $(this).hide().next().show()), execution order doesn't matter too much here.
- Code:
$(".collapse img[alt='Close']").click(function(){
my_setcookie($(this).parent().attr("id"),1,2,0);
$(this).hide().next().show();
$(this).parent().parent().next().slideUp()
});
$(".collapse img[alt='Open']").click(function(){
my_setcookie($(this).parent().attr("id"),0,2,0);
$(this).hide().prev().show();
$(this).parent().parent().next().slideDown()
});
Inside the first event handler (which is for [alt='Close']) add the statement below. It can be after or before any of the existing statements (e.g. $(this).hide().next().show()), execution order doesn't matter too much here.
- Code:
$(this).closest('.main-head').addClass('category_hidden');
- Code:
$(this).closest('.main-head').removeClass('category_hidden');
- Code:
.category_hidden {
/* style properties */
}
Similar topics
» Toggle Button in Description
» how can I make a profile toggle button
» Cant get toggle to work
» Graphic Request: Small Button for Widget Toggle
» Need help with javascript to hide button
» how can I make a profile toggle button
» Cant get toggle to work
» Graphic Request: Small Button for Widget Toggle
» Need help with javascript to hide button
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum