Jump to content

FadeTo() on <body> with Toggle()


jamesjmann

Recommended Posts

Hi, I'm wanting to toggle the opacity of the background everytime some clicks on the "control panel" button. It's initially hidden and if they click on it, it slowly fades in. If they click again, it slowly fades out; this was achieved using a simple fadeToggle. So far so good. Now, at the same time, I want the background (<body>) to slowly fadeTo an opacity of about say "0.5"; and then, of course, back to "1.0" if clicked again. Does anyone know of a good toggle function that can allow such a thing to occur?

 

Here's my current JQuery code. Can someone please insert that toggle function in my current function where it needs to go? Thanks in advance!

function slide_me() {
$("#controlPanel").fadeToggle(500);	
        <!--I'm assuming it would go here...?-->
}

$(document).ready(hide_panel);

function hide_panel() {
$("#controlPanel").hide();
}

 

EDIT: Another thing, is as soon as the document loads (or is "ready"), the control panel div is not being hidden. No idea what the problem here is with that. Does anyone see anything wrong in my code?

Link to comment
https://forums.phpfreaks.com/topic/232914-fadeto-on-with-toggle/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.