Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 652323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:15:36+00:00 2026-05-13T22:15:36+00:00

**Nevermind. I figured it out. ** I did it like this: $(#accordion).accordion({ header:’h3′, active:

  • 0

**Nevermind. I figured it out. **

I did it like this:

$("#accordion").accordion({
        header:'h3',
        active: '#section1',
        autoheight: false,
        clearstyle: true,
}).bind("change.ui-accordion", function(event,ui) {
    $("#text1").focus();
});

I’ve got an accordion all set up, and each div has a form within it. I’m just trying to figure out how to set the focus on an input field depending on which one is open…

/* accordion */
$("#accordion").accordion({
        header:'h3',
        active: '#section1',
        autoheight: false,
        clearstyle: true
});

Basically, I want to set the cursor in the first input field for whichever section is open. The actual forms are much bigger, so I condensed it enormously…

    <div id="accordion">
        <h3 id="section1"><a href="#">Section 1/a></h3>
        <div>
            <form id="form1" action="form.php" method="post">
                <fieldset class="inside">
                    <input type="text" name="text1" id="text1" size="50" value="Default text" />
                    <input class="open" type="button" value="Submit" name="submit1" />
                </fieldset>
            </form>
        </div><!--/div-->

        <h3 id="section2"><a href="#">Section 2</a></h3>
        <div>
            <form id="form2" action="form.php" method="post">
                <fieldset class="inside">
                    <input type="text" name="text2" id="text2" size="50" value="Submit" />
                    <input class="open" type="button" value="Submit" name="submit2" />
                </fieldset>
            </form>
        </div><!--/div-->

        <h3 id="section3"><a href="#">Section 3</a></h3>
        <div>
            <form id="form3" action="form.php" method="post">
                <fieldset class="inside">
                    <input type="text" name="text3" id="text3" size="50" value="Submit" />
                    <input class="open" type="button" value="Submit" name="submit3" />
                </fieldset>
            </form>
        </div><!--/div-->
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:15:36+00:00Added an answer on May 13, 2026 at 10:15 pm
    $("#accordion").accordion({ header:'h3', active: '#section1', autoheight: false, clearstyle: true, }).bind("change.ui-accordion", function(event,ui) { $("#text1").focus(); });
    

    That’s not going to work for the other sub-accordions. As you’re hard-coding the ID of the textbox to focus.

    It’s probably possible to hook into something on that change.ui-accordion event but I’m not terribly familiar with it. You could use something like this:

        $(document).ready(function() {
            $("div#accordion > h3 > a").click(function(e) { // when we click a link
    
                e.preventDefault(); // prevent the click from bubbling
    
                var parenth3 = $(this).parent(); // find the parent h3 the sender is in
    
                //this selector then finds the first textbox that is in the div adjacent to the parent h3.
                $("#" + parenth3[0].id + " + div > form > fieldset.inside > input[type=text]:first").focus();
    
            });
        });
    

    This feels pretty hacky to me.

    Edit: Also note that your anchor tag for Section 1 is not closed properly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

** EDIT ** Nevermind, just needed to take out the parens... I get this
let say i have a string like this neverMind<b>What is up</b>neverMind and I want
Nevermind, I just figured out that CakePHP had to re-set the cookie because it
Edit: nevermind, figured it out, answer below if you're interested. Using Postgresql 8.4. Here's
Sometimes, when I look through my header files I'd like to add something little
I am using jQuery ColorPicker Plugin and I would like to use this multiple
UPDATE: My mistake - I made a typo. Nevermind this question. I'm using php
I have an if statement like the below if false { expr } It
-edit- nevermind i was lucky and didnt need to change much and have this
EDIT: I have figured out my main issue, but still have one concern. Everything

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.