Translate

2012年3月12日 星期一

javascript 計算字數範例(The number of calculations examples)

<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta name="generator" content="PSPad editor, www.pspad.com">
  <title></title>
  </head>
  <body>
            <textarea name="text" cols="50" rows="10" onkeyup="Count_words(this);"></textarea>
                        Input: <span id="txt">0</span> Words       
                           
  </body>
</html>
<script>
function Count_words(objElement) //計算字數
{   
    var now_word = document.getElementById("txt");
    Count_num = objElement.value.length;
    now_word.innerHTML = Count_num;
}
</script>

沒有留言:

張貼留言