2015-04-06 2 views
-1

Использование бутстрапа и не может установить ввод в скрытый. Он может быть легко спрятан с помощью JS, используяКак установить элемент ввода формы в скрытое?

document.getElementById("inputCommentsBrand").style.visibility = "hidden"; 

, но я бы хотел, чтобы оно было скрыто по умолчанию.

<div class="form-group"> 
     <label for="inputComments" class="col-sm-2 control-label">Markings</label> 
     <div class="col-sm-4"> 
      <div><input hidden type="text" class="form-control" id="inputCommentsBrand" name="inputFlags[]" placeholder="Brand and Location: Sbar RH"></div> 
      <div><input type="text" class="form-control" id="inputCommentsEarTag" name="inputFlags[]" placeholder="Ear Tag Color & #: Green 165"></input></div> 
     </div> 
    </div> 

ответ

0

Используйте <body onload="myFunction()">, чтобы скрыть это поле.

Ниже приведен пример работы.

<script> 
 
function myFunction() { 
 
    document.getElementById("inputCommentsBrand").style.visibility = "hidden"; 
 
} 
 
</script> 
 

 
<html> 
 
    
 
<body onload="myFunction()"> 
 

 
    <div class="form-group"> 
 
     <label for="inputComments" class="col-sm-2 control-label">Markings</label> 
 
     <div class="col-sm-4"> 
 
      <div><input type="text" class="form-control" id="inputCommentsBrand" name="inputFlags[]" placeholder="Brand and Location: Sbar RH"></div> 
 
      <div><input type="text" class="form-control" id="inputCommentsEarTag" name="inputFlags[]" placeholder="Ear Tag Color & #: Green 165"></input></div> 
 
     </div> 
 
    </div> 
 

 
</body> 
 
</html>

-1

Вместо видимости: скрытый Использование дисплея: нет

Смежные вопросы