JQuery Code Add to Anchor ?

Hi all,

I have a script which uses this code to navigate between tabs:

$('#formElem > fieldset').each(function(){
            var $fieldset = $(this);
            $fieldset.children(':last').find(':input').keydown(function(e){
                  if (e.which == 9){
                        $('#navigation li:nth-child(' + (parseInt(current)+1) + ') a').click();
                        /* force the blur for validation */
                        $(this).blur();
                        e.preventDefault();
                  }
            });
      });

I need to be able to call this from an anchor.

Right now I click on the different li's to navigate:

Here's the code:

<div id="navigation" style="display:none;">
                    <ul>
                        <li class="selected">
                            <a href="#">STEP 1</a>
                        </li>
                        <li>
                            <a href="#">STEP 2</a>
                        </li>
                        <li>
                            <a href="#">STEP 3</a>
                        </li>
                        <li>
                            <a href="#">STEP 4</a>
                        </li>
                                    <li>
                            <a href="#">STEP 5</a>
                        </li>
                                    <li>
                            <a href="#">STEP 6</a>
                        </li>
                    </ul>
                </div>

As you can see there's no links so I don't know how to navigate this from some of my links on the same page.

Can anyone help please?


error77Asked:
Who is Participating?
 
Atique AnsariConnect With a Mentor Commented:
I am not sure what do you want to achieve. Below code may help you.

 
<div id="navigation" style="display:none;">
	<ul>
		<li class="selected">
			<a href="#" id="step1">STEP 1</a>
		</li>
		<li>
			<a href="#" id="step2">STEP 2</a>
		</li>
		<li>
			<a href="#" id="step3">STEP 3</a>
		</li>
		<li>
			<a href="#" id="step4">STEP 4</a>
		</li>
		<li>
			<a href="#" id="step5">STEP 5</a>
		</li>
		<li>
			<a href="#" id="step6">STEP 6</a>
		</li>
	</ul>
</div>

<script language="javascript" type="text/javascript">
	jQuery(document).ready(function($)
	{
		$("a#otherLink1").live('click', function(e)
		{
			e.preventDefault();
			$("#step1").trigger('click');
		});
	});
</script>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.