vendredi 19 janvier 2018

Fade in and out elements via checkbox with javascript and jquery

So, I want to fade in and out a <div> with a checkbox and jquery. The <div>, which should get faded in/out, has the id "jobstartdatefade". The checkbox-id is "jobfixedstart". The Browser gives back the error "Uncaught SyntaxError: Unexpected token ;"

Here is my javascript code:

            //Setting the checked status to false
            document.getElementById("jobfixedstart").checked = false;


            document.getElementById('jobfixedstart').onclick = function(){

            if(document.getElementById("jobfixedstart").checked == false;){
            $('#jobstartdatefade').fadeIn(200); 
            document.getElementById("jobfixedstart").checked = true;    
            }

            if(document.getElementById("jobfixedstart").checked == true;){
            $('#jobstartdatefade').fadeOut(200);    
            document.getElementById("checkbox").checked = false;    
            }
            };

The HTML code for the checkbox looks like this:

      <input type="checkbox" class="form-control" value="jobfixedstart" id="jobfixedstart" />

And the <div>, which should get faded in in html looks like that:

<div id="jobstartdatefade">Text<div>

Thank you




Aucun commentaire:

Enregistrer un commentaire