jQuery實現微博字數統計

2021-06-15 08:27:08 字數 1455 閱讀 1566

xhtml

class="clear"

>

id="saywrap"

>

class="saylist"

>

href="#"

>

src="images/user.gif"

alt=""

/>

class="saytxt"

>

>

>

href="#"

>demo

發布的內容...

class="date"

>

class="clear"

>

xhtml是乙個表單,裡面有輸入框textarea,發布按鈕,還有乙個統計輸入字數的span#counter,和資訊提示span#msg,在沒有輸入的情況下就提交則會提示使用者要求輸入內容。

css

h3 

h3span 

.input 

.sub_btn 

#msg 

.clear 

.saylist 

.saylist

img 

.saytxt 

.saytxt

p .saytxt

pstrong 

.date

jquery

先引入jquery庫和global.js檔案:

global.js檔案:

global.js要做的事有:

1、使用者輸入、滑鼠離開輸入框時,統計輸入的字元數,並根據輸入字數的不同而輸出不同的樣式(字型顏色)顯示在頁面上。

具體**如下:

function recount()

else 

$('input.sub_btn').removeattr('disabled'); 

if(current<10) 

$('.counter').css('color','#d40d12'); 

else

if(current<20) 

$('.counter').css('color','#5c0002'); 

else 

$('.counter').css('color','#cccccc'); 

}

函式recount()完成了輸入字元的統計,並根據輸入的字元數,顯示不同的字型顏色。

$(function()); 

$("#myform").submit(function() 

$('.counter').html('

$.ajax(

}}); 

return false; 

}); 

});

書籍字數統計

統計始章節和書籍的字數 update chapter set fontcount len cast content as varchar 8000 update book set finishcount pp.fontcount from book inner join select sum fon...

Python 哈姆雷特字數統計

def gettext 賦予txt哈姆雷特 全英文小寫 全符號變空格 返回txt txt open c users eternal desktop hamlet.txt r read 路徑要選好 txt txt.lower for ch in txt txt.replace ch,return tx...

python 哈姆雷特 字數統計 詞云

def gettext 賦予txt哈姆雷特 全英文小寫 全符號變空格 返回txt txt open hamlet.txt r read 注意文字的路徑 txt txt.lower 文字字元全部轉變為小寫字母 for ch in txt txt.replace ch,使用空格字元替換掉文字中所有特殊字...