0

The code underneath will show Fax and an input-box. I manage to hide the text "Fax" but I'm not able to hide the input-box. How can I hide the input-box using CSS and Javascript?

<div class="field">
    <label for="billing:fax">Fax</label>
    <div class="input-box">
       <input id="billing:fax" class="input-text " type="text" title="Faxnummer"    value="" name="billing[fax]">
    </div>
</div>
4
  • you can try .input-box > input {display:none;} Commented Jul 7, 2015 at 20:12
  • "I manage to hide the text Fax" So how'd you do that? And where's the CSS you tried? Commented Jul 7, 2015 at 20:13
  • Here's the CSS code that hide the text Fax: label[for="billing:fax"] { display:none; } Commented Jul 7, 2015 at 20:20
  • And did you try using display:none with your input? Commented Jul 7, 2015 at 20:24

3 Answers 3

1

To hide that specific input you can select it by the ID, but you need to escape the :

#billing\:fax {
  display: none;
}
<div class="field">
  <label for="billing:fax">Fax</label>
  <div class="input-box">
    <input id="billing:fax" class="input-text " type="text" title="Faxnummer" value="" name="billing[fax]">
  </div>
</div>

There are of course, many ways to select an element in CSS. Another way would be to use the adjacent sibling (+) and descendant (>) selectors to get to the input:

 label[for="billing:fax"] + div.input-box > input
Sign up to request clarification or add additional context in comments.

Comments

0

You can use Javascript to toggle the input property type="hidden" for the input box.

http://www.echoecho.com/htmlforms07.htm

Comments

0

display: none; is your best solution if you just wanna hide the field.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.