samedi 9 janvier 2021

if statement in javascript always getting false [closed]

I am trying to get a value from a txt document with jquery in javascript and I have to check, whether it is for example green or red. The Problem I am always getting false as result of the if statement. Here is my code:

jQuery.get('https://example.de/'+secnum+"/test.txt", function(data) {
        var color = data;
        if (color == "green"){
        document.getElementById(secnum).style.backgroundImage = "linear-gradient(to top, #1b9962 0%, #96d581 100%)";
        }

Thank you for your help!

Aucun commentaire:

Enregistrer un commentaire