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 8982119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:30:26+00:00 2026-06-15T20:30:26+00:00

I have a form with inputs and and div container outside of form with

  • 0

I have a form with inputs and and div container outside of form with help text for each input.

<form>
    <input id="name" />
    <input id="email" />
    <input id="pass" />
</form>
<div class="help-container">
    <p class="help-name"></p>
    <p class="help-email"></p>
    <p class="help-pass"></p>
</div>

Now the .help-container is initially hidden with { display: none; } as well as each child p.

The jQuery I’m having trouble with is:

$("form").find("input").focus(function(){
    var parent = $(this).attr("id");
    $(this).closest("form").next(".help-container").show();
})

1) This does not work. Why?

$("form").find("input").focus(function(){
    var parent = $(this).attr("id");
    $(this).closest("form").next(".help-container").show();
    $(".help-container").children("p").hide();
    $(".help-container").children("p").find(".help-" + parent).show();
})

2) This does not work. Why?

  • 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-06-15T20:30:27+00:00Added an answer on June 15, 2026 at 8:30 pm

    Here are your issues

    $("form").find("input").focus(function(){
        var parent = $(this).attr("id");
        $(this).closest("form").next(".help-container").show(); // you show the container
        $(".help-container").children("p").hide(); // hide all p under it - nothing is shown now
        $(".help-container").children("p").find(".help-" + parent).show(); // you're trying to find elements under p with class .help-xxx
    })
    

    You need to change it to this

    $("form input").focus(function(){
        var parent = $(this).attr("id");
        $(".help-container").children("p").hide();    // hide all p's
        $(".help-container").children("p.help-" + parent).show(); // show relevant p - since you want the p with the matching class
    });​
    

    http://jsfiddle.net/vjUme/

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

Sidebar

Related Questions

I have form like this: <div class=satu> <input type='text' size='1' maxlength='1' name='score[1][]' id='score[1][]'> </div>
I have this form: <form> <div class=box> <h1>Contact form :</h1> <label> <span>Typ: </span> <input
I have an input form, nested within a div, defined like this: <div class=login-input>
I have the following html <form action= class=form-horizontal id=submitForm> <input class=required input-xxlarge type=text placeholder=Please
I have the following html: <div class=container-fluid> <div class=row-fluid> <div class=span8> <form class=form-horizontal> <div
I have a template <script id=template type=text/x-jquery-tmpl> <div class=experience> <label for=c${count}>New Thing:</label> <input type=text
I have a form with some input fields and a little <div> to the
I have a form with inputs, the Jquery makes a specific input (the url
I currently have a form with inputs and name attributes. I'm able to get
I have a form with 2 text inputs and 2 radio buttons, as below:

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.