源代码:复制代码代码如下:DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN ' ' http://www .w3。L1-过渡时期。DTD ' html xmlns=' http://www .w3。org/1999/XHTML ' head meta http-equiv=' Content-Type ' Content=' text/html;charset=utf-8'/title发布框/title脚本src='http:/scripts/jquery-1。3 .1 .js ' type=' text/JavaScript '/script!-功能描述:当点击输入框时,提示的文字会去掉;当光标离开时,如果没有输入任何内容,提示的文字会恢复;如果有输入文字,将会计算并显示剩余的字数-脚本类型=' text/JavaScript ' $(function(){ $(' # content ')).focus(function(){ if ($(this)).val()==这个。DefaultValue){ $(this).val(" ");//alert($(this).长度-1);} }).模糊(函数(){ if ($(this)).val()=='') { $(this).瓦尔(这个。default value);} }) $('#content ').向上键(function(){//alert($(this)).val().长度);var word _ num=140-$(这个)。val().长度;if (words_num 0) { //被误导了这样是不会有返回值的//$(“font”).text(function(words _ num){//return ' font color=' red ' ' words _ num '/font ';//});$("字体")。css(“”颜色','红色')。文本(word _ num);}else{ $('font ').文本(word _ num);//alert(words _ num);} }) });$(function(){ $(“# send”)).单击(函数(){ $).post('post3.php ',{ //username : $('#username ')).val(),内容: $('#content ').val() },函数(数据,textStatus){//var username=data。用户名;var content=data . content//var txtHtml=' div class=' comment ' h6 ' username ' :/h6p class=' para ' ' content '/p/div ';var txtHtml='divh3 '内容/H3/div ';$('#resText ').html(TxTHtml);//把返回的数据添加到页面上},' JSON ');}) });/script/head body字段设置style=' width :800 px左边距左侧:300像素图例样式=' font-sixe :16 px;字体粗细:600 '发布框/legend form action='#' id='form1 '!-enctype=' multipart/form-data '-您还可以输入span id=' num ' style=' font-size :28 px;font-weight :800 ' font color=' green ' 140/font/span个字textarea cols='96 '行='8' id='content '随便写点东西吧/textarea输入类型='button' id='send '值='发布//表单/字段集差异你发送的信息是:/div div id=' resText '/div/body/html效果图
遇到的问题:主要就是jquery库的问题:使用jquery-1.3.1.js这个文件,能实现功能,但是使用jquery-1.7.1.min.js这个文件,就没有效果!害我花了很多时间去源代码找问题!