mardi 19 janvier 2016

Javascript if/else statement isnt working however the code inside does as i have tested without the if/else

Basically i have tried to create an if else statement that checks the width of a div and then depending on the result will expand or contract the iframe that i have inside. Their are no problems in running the code itself just the if/else statement as i have tested the code inside without the if/else

var sc = document.getElementById("scfullscreen");
$(document).ready(function() {
$('#scfullscreen').click(function() {
    if (sc.style.left > 0) {
        $('#soundcloud').animate({
                left: '0%',
                width: '20%',
            }, 1000);
        $('#scfullscreen').animate({
                left: '0%',
                width: '20%',
            }, 1000);
        $('#scexpand').addClass('rotated');
    } else {
        $('#scfullscreen').click(function() {
            // Adjust the effect (2000 miliseconds)
            $('#soundcloud').animate({
                    left: '20%',
                    width: '80%',
                }, 1000);
            $('#scfullscreen').animate({
                    left: '20%',
                    width: '80%',
                }, 1000);
            $('#scexpand').addClass('rotated');
        });
    }
});
});
});

Aucun commentaire:

Enregistrer un commentaire