jquery code and Chrome problem

Asked

Viewed 240 times

0

I’m having a hard time with the following jquery code.

JQUERY

$(document).ready(function(){
     $('#expand').click(function(){
        $(".container-fluid").slideToggle("slow");
     });
});


$(document).ready(function(){
     $('#expand2').click(function(){
        $(".container-fluid2").slideToggle("slow");
     });
});

I have 2 buttons (id=expand and id=expand2) that perform these functions respectively, the problem is that in Chrome the 2nd button literally disappears the content that is inside the div .container-fluid2, already div .container-fluid is always run correctly. I tried it on Firefox and everything worked perfectly because I am having problems with Chrome?

  • try searching like this in google: "jquery slidetoggle Issue Chrome"

  • 1

    Can you make a jsFiddle that reproduces the problem? I don’t see how that can happen...

  • Why don’t you just put it all in one $(Document). ready(Function(){});

1 answer

0

You got the <script url="tuafontedoJquery"></script> added?

That’s probably why the chorme does nothing because you don’t have any jquery in the cache.

  • I do, and jquery works, but only with the first slidetoggle effect, already with the second, when I click to expand it disappears from the page and never goes back to the original formation, firefox works well, only in Chrome that no, I’ve seen some posts, but still not understood how to solve the problem, have some kind of CSS HACK to fix the problem?

  • var escondido = true;&#xA;$(document).ready(function(){&#xA; $("#expand").click(function(){&#xA; if(escondido)&#xA; {&#xA; $(".container-fluid").show();&#xA; escondido = false;&#xA; }&#xA; else&#xA; {&#xA; $(".container-fluid").hide();&#xA; escondido = true;&#xA; }&#xA; });&#xA;}); I haven’t used Javascript for some time but this should work.

  • @Hardcore Hardcore really solved the problem, but I ran out of slideToggle slider effect.... that was not quite what I intended, I tried to add in your code a toggle("slow"), but it gets the same behavior as my initial code, the window when it expands does not go back to the initial format. I still can’t understand why it doesn’t work on Chrome since in firefox slideToggle works perfectly, without errors!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.