博客效果,你还可以输入xx个字
自己做的一些博客效果,以供参考,刚学习的,还记不住
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> 5 <title>form3</title> 6 <script src="http://libs.baidu.com/jquery/1.7.2/jquery.min.js"></script> 7 <script> 8 $(function(){ 9 var maxLength = 140; 10 $('textarea').keyup(function() { 11 var l = $(this).val().length; 12 $('strong').text(maxLength-l); 13 if(parseInt($('strong').text()) < 0){ 14 $('strong').text('0'); 15 var val = $(this).val().substring(0,140); 16 $(this).val(val); 17 } 18 }); 19 }); 20 </script> 21 </head> 22 <body> 23 <textarea name="" id="" cols="30" rows="10"></textarea> 24 <span>你还可以输入<strong style="font-weight:bold; color:red;">140</strong>个字</span> 25 </body> 26 </html>