mardi 28 janvier 2020

JS If Else madnes

Ok I am relatively new to JS and JQuerry, but have plenty of experience with other languages to know this should be alright. And it's starting to drive me mad.

Can somebody, please, explain to me why the code wont fire the second condition in this block? Am I missing something?

if (element === '#fs1' || element.attr('id') === "fs1")
    {
        $("#fs1liuwc").show("slow"); 
    }
    else if (element === '#fs2' || element.attr('id') === "fs2")
    { 
        $("#fs2liuwc").show("slow");
    }
    else if (element === '#fs3' || element.attr('id') === "fs3")    
    { 
        $("#fs3liuwc").show("slow"); 
    }

So the first one where the element is #fs1 is ok, everything works fine, but on the second and third one it just skips the rest of the script. I am calling this function from this one:

function ClickResize(sender)
{
   $(sender).click(function()
   {
     ResizeElement(sender);  
   });
}

Witch is written in the:

$(document).ready(function(){  

   ClickResize('#fs1');
   ClickResize('#fs2');
   ClickResize('#fs3');

});

Aucun commentaire:

Enregistrer un commentaire