www.webdeveloper.com
Results 1 to 6 of 6

Thread: [RESOLVED] please simplify this for me, thanks

  1. #1
    Join Date
    Mar 2009
    Posts
    48

    resolved [RESOLVED] please simplify this for me, thanks

    hi guys,
    can someone put this into an array for me please--don't know much about js.. much obliged for your help

    btw...when I call the site from google, the divs are open but when I call the site from my browser address bar...the divs are hidden as should be (only in firefox, otherwise great.

    Any ideas why that might be?

    thanks a ton
    DD

    Code:
    jQuery(document).ready(function() {
      jQuery(".content").hide();
      //toggle the componenet with class msg_body
      jQuery(".headinga").click(function()
      {
        jQuery(this).next(".content").slideToggle(500);
      });
    });
    jQuery(document).ready(function() {
      jQuery(".content").hide();
      //toggle the componenet with class msg_body
      jQuery(".headingb").click(function()
      {
        jQuery(this).next(".content").slideToggle(500);
      });
    });
    jQuery(document).ready(function() {
      jQuery(".content").hide();
      //toggle the componenet with class msg_body
      jQuery(".headingc").click(function()
      {
        jQuery(this).next(".content").slideToggle(500);
      });
    });

  2. #2
    Join Date
    Oct 2005
    Location
    Cambridgeshire, UK
    Posts
    191
    Try this:

    Code:
    jQuery(document).ready(function() {
    
        jQuery(".content").hide();
    
        jQuery(".headinga").click(function() {
            jQuery(this).next(".content").slideToggle(500);
        });
    
        jQuery(".headingb").click(function() {
            jQuery(this).next(".content").slideToggle(500);
        });
    
        jQuery(".headingc").click(function() {
            jQuery(this).next(".content").slideToggle(500);
        });
    
    });
    Not quite sure what you mean by put it into an array. Do you mean there could be an unlimited number of headings? If so, try this:



    Code:
    jQuery(document).ready(function() {
    
        jQuery(".content").hide();
    
        // select all elements with a class beginning with 'heading'
        jQuery('[class^="heading"]').click(function() {
            jQuery(this).next(".content").slideToggle(500);
        });
    
    });
    Try that and let us know how you get on

  3. #3
    Join Date
    Mar 2009
    Posts
    48
    Thanks for the quick help BIOSTALL :-=

    The "array" works fine thankyou(much smaller and not having to recall the function every time) that was the point....BUT,

    When I call my website from google search and open the site(with FireFox), the divs are open(should be closed).
    When I refresh the browser or enter the address directly into the browser address bar, they are closed(as should be)

    It's as if the jquery.min.js is being called too late when calling the site indirectly. I put the above script into the <head> so that is oviously being called on time.

    I tried calling jquery.min.js from my server and from google direct with no change

    THX
    DD
    Last edited by dododidi; 11-19-2010 at 03:40 PM.

  4. #4
    Join Date
    Oct 2005
    Location
    Cambridgeshire, UK
    Posts
    191
    Do you have a link to the site? Also, it might not make a difference but are you calling the jquery.js from within the <head></head> section of your site?

    I've never heard of the issue with regards to the divs being when open coming from a search engine :-S Could be some weird browser caching. Have you tried on another PC or in another browser?

  5. #5
    Join Date
    Mar 2009
    Posts
    48
    just sent you a PM mate,

    I've tried calling from my server and from google direct(both as external files)

    IE is perfect

    I have tried deleting my cache, with no effect

    EDIT: Now I have noticed that the divs are also open when clicking the post from the homepage, but as said, if I refresh the page or enter it directly into the address bar..it's closed(only in FireFox ver. 3.6.12) strange!

    DD
    Last edited by dododidi; 11-19-2010 at 04:28 PM.

  6. #6
    Join Date
    Mar 2009
    Posts
    48
    Well guys BIOSTALL helped so damned quickly and sorted the problem out for me...Bow my head to you mate

    Thanks a ton "BIOSTALL RULES"
    DD
    Last edited by dododidi; 11-19-2010 at 04:50 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles