熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

jquery實現判斷輸入文字個數的代碼

2013-11-15 12:06:02  來源: JSP教程 

  js代碼部分

  <script type="text/javascript">
$(function() {

  function albumName() {
var text = $("#album_name")val();
var counter = textlength;
$("#numtj var")text(counter);
$(document)keyup(function() {
var text = $("#album_name")val();
var counter = textlength;
$("#name_word")text(counter);
});
}
});
</script>

  html部分

  <input type="text" maxlength="" class="int_txt" name="album_name" id="album_name">
<span class="count_txt"><span id="name_word"></span>/</span>

  貼張圖看下效果

  js代碼部分

  <script type="text/javascript">
$(function() {

  function albumName() {
   var text = $("#album_name")val();
var counter = textlength;
   $("#numtj var")text(counter);
$(document)keyup(function() {
 var text = $("#album_name")val();
  var counter = textlength;
$("#name_word")text(counter);
});
 }
  });
</script>

  html部分

  

  <input type="text" maxlength="" class="int_txt" name="album_name" id="album_name">
<span class="count_txt"><span id="name_word"></span>/</span>

  貼張圖看下效果

  js代碼部分

  <script type="text/javascript">
$(function() {

  function albumName() {
   var text = $("#album_name")val();
var counter = textlength;
   $("#numtj var")text(counter);
$(document)keyup(function() {
 var text = $("#album_name")val();
  var counter = textlength;
$("#name_word")text(counter);
});
 }
  });
</script>

  html部分

  <input type="text" maxlength="" class="int_txt" name="album_name" id="album_name">
<span class="count_txt"><span id="name_word"></span>/</span>


From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20280.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.