2014-02-22 111 views
0

我有這個腳本的問題。CSS文本對齊屬性無法正常工作

輸出不與中心對齊;只有紅色才能正常工作。

<script>  
    $(document).ready(function() { 
     $("#register_form input").focus(function() { 
      $("#status").fadeOut(800); 
     }); 

     $("#pass1").keyup(function() { 
      if ($(this).val().length < 6) { 
       $("#output_pass1").css("color", "red").css('text-align', 'center').html("<br/><br/>very short "); 

      } 
     }); 
    }); 
</script> 

,這是HTML代碼:

<label for="pass1">Password :</label> 
<div class="col-sm-5"> 
    <input type="Password" id="pass1" placeholder="Enter your password " required> 
</div> 

<small id="output_pass1" ></small> 
+0

請顯示更多的html代碼。 – Akhlesh

+0

我編輯了我的代碼 –

+2

你能提供一個小提琴的工作? –

回答

1

請給元素display: block;,太:

small { display: block; } 

$("#output_pass1") 
.css({"color":"red", "text-align":"center", "display": "block" }) 
.html("<br/><br/>very short "); 

小提琴:http://jsfiddle.net/aslancods/NDNYF/5/

+0

問題是由阿斯蘭解決,非常感謝你先生! –

+0

不用期待John Low, 謝謝牙刷修正語法錯誤。 – sudhnk