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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:30:02+00:00 2026-05-30T07:30:02+00:00

On one part of my website, I have a text label, a text input

  • 0

On one part of my website, I have a text label, a text input box and a label behind the box (the label specifies the unit). I want these to be visible/invisible depending on whether a radiobutton is checked.

The html part is currently as follows:

<span id="txtLabelInFronOfBox">Some text</span>
<input id="textBoxInput" size="3" class="numeric" pattern="[0-9]+" type="text">
<span id="txtUnit">A</span>

The reason why I’m using the span tag here and not simply just type the text, is that I need to have some ID for the text, to access it from the Jquery part. Here’s the Jquery part:

$('#rbtMyRadioButton').change(function() {
  if ($('#rbtMyRadioButton').is(':checked')){
    $('#txtLabelInFronOfBox, #textBoxInput, #txtUnit').css('display', 'block');
  }
});

The reason why I’m using ‘display’ and not ‘visible’/’invisible’ is that I want the space these controls occupy to disappear when they are not visible. This works fine, except that for some reason this creates a line shift after each control, i.e. when I check the radio button, these controls appear, but there is a line shift after txtLabelInFronOfBox, one after textBoxInput and one after txtUnit.

Any suggestions to what I can do to not get these line shifts?

Initially I just created a paragraph around all these controls, gave the paragraph an ID and accessed the ID from the Jquery. Then I checked the code of my page on an html validator, and it said that this was not according to the HTML5 standard. That’s a pity, because that worked exactly like I wanted.

  • 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-30T07:30:04+00:00Added an answer on May 30, 2026 at 7:30 am

    By “line shift” I assume you mean that each element starts on a new line. This is happening because you are setting display: block and by default block elements start on a new line.

    You could instead say:

    $('#txtLabelInFronOfBox, #textBoxInput, #txtUnit').css('display', 'inline');
    // OR
    $('#txtLabelInFronOfBox, #textBoxInput, #txtUnit').css('display', '');
    

    “inline” is the default for spans and inputs. If you set display to an empty string then it should fall back to the default as specified in your stylesheet or (if not specified) the default for the element type (“inline” in this case).

    Regarding wrapping the elements in a paragraph and that not being valid html5, try using a div element instead.

    Rather than setting display directly yourself, try jQuery’s .show() and .hide() methods:

    $('#txtLabelInFronOfBox, #textBoxInput, #txtUnit').show();
    

    Demo: http://jsfiddle.net/nnnnnn/Hmrnq/1/ (thanks to Amar for creating the starting fiddle)

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

Sidebar

Related Questions

I am bringing in a particular div (.source_div) from one part of my website
I want to relocate some controls from one part in the visual tree to
I have some code that at one part will get executed a lot, and
I have an ASP.NET MVC application that has one part where I dont really
I am upgrading part of a very old website. One of the pages that
I have a website which draws white (empty) content/text on IE 7. However, as
One one part of my website, there are 3 things: 2 pictures and one
On an existing website, one block of text is displaying too large on an
I am trying to highlight a part of the text on my website. This
one part of my applikation covers an MkMapview. Therefore i load a list of

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.