1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

.slideToggle issue in Firefox

Discussion in 'jQuery' started by telkins, Feb 18, 2014.

  1. #1
    Hello. My site http://charleybiggs.com.s64567.gridserver.com/ is working properly in Chrome and Safari. When you click on certain boxes, specific divs load at the top of the page. In Firefox though these divs are automatically showing when the page loads. They are supposed to be hidden until a box is clicked. Anyone have any idea why it's doing this?

    <script type="text/javascript">
        jQuery(function(){
          jQuery("#music").click(function () {
            jQuery("#musicinfo").slideToggle('slow');
            jQuery("#fpinfo, #behindinfo, #behindinfo, #signupinfo").hide('slow');
    
          });
        });
    </script>
    
    
    
    
    
    <script type="text/javascript">
        jQuery(function(){
          jQuery("#fproduct").click(function () {
            jQuery("#fpinfo").slideToggle('slow');
            jQuery("#musicinfo, #behindinfo, #behindinfo, #signupinfo").hide('slow');
    
          });
        });
    </script>
    
    
    
    
    <script type="text/javascript">
        jQuery(function(){
          jQuery("#behind").click(function () {
            jQuery("#behindinfo").slideToggle('slow');
            jQuery("#fpinfo, #musicinfo").hide('slow');
    
          });
        });
    </script>
    
      <script type="text/javascript">
        jQuery(function(){
          jQuery(".exit").click(function () {
            jQuery("#behindinfo, #musicinfo, #fpinfo, #signupinfo").hide('slow');
           
          });
        });
    </script>
    
    <script type="text/javascript">
        jQuery(function(){
          jQuery("#signup").click(function () {
            jQuery("#signupinfo").slideToggle('slow');
            jQuery("#fpinfo, #musicinfo, #behindinfo").hide('slow');
    
          });
        });
    </script>
    
      <script type="text/javascript">
        jQuery(function(){
          jQuery(".exit").click(function () {
            jQuery("#behindinfo, #musicinfo, #fpinfo, #signupinfo").hide('slow');
           
          });
        });
    </script>
    
    Code (markup):
     
    telkins, Feb 18, 2014 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    All those could be combined into one function...
    Something along the lines of
    $("#selector1,#selector2").click(function() {
    $(this).show();
    }) 
    Code (markup):
    And so forth
     
    PoPSiCLe, Feb 18, 2014 IP
  3. telkins

    telkins Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    Sorry, I've never really used jquery before! I figured there was a way. Do you think that might be the issue?
     
    telkins, Feb 18, 2014 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    You also haven't done this within the $(document).ready() function...
    I'm sorry, I'm on mobile, else I would rewrite it.
     
    PoPSiCLe, Feb 18, 2014 IP
  5. telkins

    telkins Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    No problem. I wrapped it in the $(document).ready() function and the functionality is still off in Firefox. Works beautifully in Safari and Chrome though!
     
    telkins, Feb 18, 2014 IP
  6. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #6
    Nope. It works just fine in both FF and Chrome. Maybe you have either a weird plugin or something running in Firefox, or perhaps there is a problem with the version of Firefox you're running?
     
    PoPSiCLe, Feb 18, 2014 IP
  7. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #7
    Besides - with a little bit of refactoring, I think you could rewrite the whole bit to something like this:
    
    <script type="text/javascript">
    $(document).ready(function() {
      $('.toggle').click(function() {
      var getID = $(this).attr('id');
      $('#'+getID+'info').slideToggle('slow');
      $(".toggleinfo").not('#'+getID+'info').hide('slow');
      })
      $('.exit').click(function() {
      $('.toggleinfo').hide('slow');
      })
    })
    </script>
    
    Code (markup):
    Which basically gets the ID from the currently clicked item (.toggle) and hides all with class (.toggleinfo) - this will of course mean that you will have to do a rename so that all the .toggle-IDs correspond to the ID+info-bits.
    Untested, but it should work.
     
    PoPSiCLe, Feb 18, 2014 IP