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

  • Home
  • SEARCH
  • 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 8125065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:41:08+00:00 2026-06-06T06:41:08+00:00

I have a form with some input fields and a little <div> to the

  • 0

I have a form with some input fields and a little <div> to the right of each input with a little description. What I want is to enable a CSS class for each input’s own <div> with it’s own description.

I have made a working example here: http://jsfiddle.net/VL2FH/8/.
This uses the <div> :hover state on the input’s focus state.

What I want to ask is: Is there some sort of a “shortcut” so I don’t have to make:

$('#submit_name').bind('blur', function(){
   $('#submit_name-desc').removeClass('input-desc-hover').addClass('input-desc');
});
$('#submit_name').bind('focus', function(){
  $('#submit_name-desc').removeClass('input-desc').addClass('input-desc-hover');
});
​

For each input field in the form.

  • 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-06T06:41:10+00:00Added an answer on June 6, 2026 at 6:41 am

    You can generalize the focus and blur callback like this

    $('input').on('blur', function(){
       $(this).next('div').removeClass('input-desc-hover').addClass('input-desc');
    }).on('focus', function(){
      $(this).next('div').removeClass('input-desc').addClass('input-desc-hover');
    });
    

    If your description divs are next to the input element, it will work fine.

    And it’s better to use .on() for event binding.
    ​

    Demo: http://jsfiddle.net/joycse06/VL2FH/11/

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

Sidebar

Related Questions

I have a form with some input fields. I am using the tabStrip KendoUI
I have a form with some generated input fields like theese: <input value=March name=month[March]
I am using ASP.NET2.0. I have created a download form with some input fields
I have one form in JSP. I have some input fields in that page,
I have a form that uses a div that is positions over some input
I have a form with some input fields: Folder Name: <input type=text id=folderName name=folderName
I have a html5 form with about 6 input fields, some being required and
I have some form input elements with class .commission_plan and different IDs. I need
I have a form with some select lists that will show/hide more input fields
I have a form with some fields in it: <form id=unit> <input type=hidden name=item_id

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.