How to force click on an accordion index (section)

Hi all,

I want to bind a click event to a selector which when clicked will open up a given part within an accordion. In the example below I want a link with an id of show-part1 to open up the first section of an accordion. My accordion has four sections. Consequently there are four ‘accordion_trigger_index’ classes with an index value from 0 to 3.

The code below triggers but it just kicks me to the top of the page and then back again, as if the $(‘.accordion_trigger_index’).click(function(){}); is firing albeit not interpreting the index value.

The accordion works fine when clicked on directly. The error must concerning forced a click event while passing the index of which accordion_trigger_index class I want it to trigger (open).

Any ideas anyone>

<script>
		$('#show-part1').bind('click', function() {
		
			$('.accordion_trigger_index').trigger('click').index(0);		
			
		});							
	 </script>

Many thanks,

Well thus far I found a way to do it as follows:

$('.accordion_trigger_index#id-name').trigger('click');

…in other words by giving each accordion_trigger_index its own unique ID.

Still have the problem of it first moving to the top of the screen before moving down and showing the correct open accordion_trigger_index. I found that if I remove the href=“” it stops doing this but then the link doesn’t appear as a link so I probably now have to do a a:hover with an underline. Seems like a awkward way round…

<a id="show-part1">SDRAM</a>

To stop the default action from occurring when the anchor link is clicked you can use a method called preventDefault() which prevents the href attribute from performing its normal action.

[CODE=JavaScript]$(‘#show-part1’).bind(‘click’, function(e) {
e.preventDefault();

// Normal jQuery code here...

});

This method works like a charm, thank you.