Avatar of smfmetro10
smfmetro10Flag for United States of America asked on

how do you open a div based on url parameter

Hi

I have some div's that need to be open and closed based on a url parameter.

Is that possible.

Here is my code so far:

<script type="text/javascript">
jQuery(document).ready(function() {
  jQuery(".menu_Specialties").show();
  //toggle the componenet with class msg_body
  jQuery(".heading1").click(function()
  {
    jQuery(this).next(".menu_Specialties").slideToggle(500);
  });
});
</script>

Open in new window

Is there a way to take :  jQuery(".menu_Specialties").show(); and wrap it in a conditional statement?

Thanks!
JavaScript

Avatar of undefined
Last Comment
Rob

8/22/2022 - Mon
plusone3055

if url parameter = x 
jQuery(".menu_Specialties").show();
else 
//do nothing 
end if

Open in new window

ASKER
smfmetro10

Thanks for the reply!

On one of sections there will be "specialty" as a parameter.

is this close?

<script type="text/javascript">
jQuery(document).ready(function() {
if url parameter = "specialty" 
jQuery(".menu_Specialties").show();
else
jQuery(".menu_Specialties").hide();
end if 
  //toggle the componenet with class msg_body
  jQuery(".heading1").click(function()
  {
    jQuery(this).next(".menu_Specialties").slideToggle(500);
  });
});
</script>

Open in new window

plusone3055

<script type="text/javascript">
jQuery(document).ready(function() {
if url parameter = "specialty" 
jQuery(".menu_Specialties").show();
//toggle the componenet with class msg_body
  jQuery(".heading1").click(function()
  {
    jQuery(this).next(".menu_Specialties").slideToggle(500);
  });

else
jQuery(".menu_Specialties").hide();
end if 
  });
</script>

Open in new window

Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER
smfmetro10

I know this is a newbie question but Dreamweaver thinks there is a syntax error with this line:

if url parameter = "specialty"
ASKER CERTIFIED SOLUTION
Rob

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question