0

I have been following tutorials from "learnnerd", a Youtube contributer. Url here I have made my website using the codes he provided. Here's my website. (check services)

I would like to link a tab on my home page to open a specific accordion in my services pages. I've researched but still know little. I don't know much about Javascript. My php/html code looks like:

<h2 class="accordion"><a href="#1"> Antenna</a></h2>
<h2 class="accordion"><a href="#2"> Digital</a></h2>

My script (from "learnnerd (Youtube)" and Atomix(here)) looks like this:

$(function(){   
   $('.accContainer').hide(); //hide all content        
   $('.accordion').click(function(){
    if( $(this).next().is(':hidden') ) {
    $('.accordion').next().slideUp();
    //triggers the hiding of contents
    $(this).next().slideDown();
    //triggers slide down of contents
    }
     return false; //prevents brower default
   });

   $(".accordion").accordion({ 
     header: "h2", navigation: true 
   }); 
}); //document.ready function

Thank you.

Lucky
  • 16,787
  • 19
  • 117
  • 151
Nehal Singh
  • 1
  • 1
  • 2

1 Answers1

0

You need to search a little more on this site. I believe this already answered question should help you:

Link to open jQuery Accordion

Community
  • 1
  • 1
user1441141
  • 606
  • 2
  • 9
  • 21
  • Hello, I have tried to use information from the link you provided but still cannot get a solution. I have editted my post and included the php/hml and script codes. Thanks. – Nehal Singh Jul 31 '12 at 07:56
  • I'm not very certain what the click function does for the accordion. If you get rid of it, I think it should work. Jquery handles all that for you when make the call to create the accordion. I don't see the purpose of that code. – user1441141 Aug 01 '12 at 03:30
  • Your accordions are empty too btw. Follow the advice in the link to create a working accordion and ditch your code. – user1441141 Aug 01 '12 at 03:34
  • You're making a classic mistake of not letting JQuery do the work, which is what I assume you are using. I threw the stuff in from the link into a jsfiddle with some modifications to show you how to directly open a link with code. Unfortunately, jsfiddle does not seem like it will let you test the navigation. http://jsfiddle.net/FXQgP/ – user1441141 Aug 01 '12 at 03:48
  • here is a working jsfiddle..modified and versionised one http://jsfiddle.net/FXQgP/4/ provided by @user1441141 – Lucky Mar 21 '13 at 07:41