/    Sign up×
Community /Pin to ProfileBookmark

[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);
});
});[/CODE]

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@BIOSTALLNov 19.2010 — 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);
});

});[/CODE]


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);
});

});[/CODE]


Try that and let us know how you get on ?
Copy linkTweet thisAlerts:
@dododidiauthorNov 19.2010 — 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
Copy linkTweet thisAlerts:
@BIOSTALLNov 19.2010 — 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?
Copy linkTweet thisAlerts:
@dododidiauthorNov 19.2010 — 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
Copy linkTweet thisAlerts:
@dododidiauthorNov 19.2010 — 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
×

Success!

Help @dododidi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...