hello, I am new with jquery. I tried to crate a toggle for change the display of the html from bright to dark when the user want to watcha video. I am doing it by clicking on an image which change when the lights are on and off. It works fine without jquery but later I wanted to add an fade effect show I change the code using jquery but the problem is that works only once (load the age with lights on, click=lights off, click again=lights on, click again=nothing). Can anyone tell me what wring?
here is the code which has the problem:
- $(document).ready(function(){
- var shadow = document.getElementById("shadow");
- $("#toggle").click(function () {
- if (shadow.style.display != "block")
- $(shadow).fadeTo("slow",0.9);
- else
- $(shadow).fadeTo("slow",0);
- });
- });
shadow is the id of an empty div which gets dark.
toggle is the id of the imahe which I am using as toggle.
thanks for any help in advance.