jquery char counter插件无法正常工作

时间:2010-11-13 16:12:24

标签: jquery counter

这是html和内部javascript

<script type="text/javascript" src="JS/jquery-1.3.2.min.js"></script>
<script src="JS/jquery.jqEasyCharCounter.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {

 $("textarea").click(function () {
   var code = $("textarea#statuspost").val();

if(code == "Fight for what's right with up to 210 bytes...")
{
     $("textarea").html("");
}

});

$('#statuspost').jqEasyCounter({
'maxChars': 210,
'maxCharsWarning': 200,
'msgFontSize': '16px',
'msgFontColor': '#d4d4d4',
'msgFontFamily': 'Verdana',
'msgTextAlign': 'left',
'msgWarningColor': 'red',
'msgAppendMethod': 'insertBefore'    
});

});
</script>


<div id="loop">
<form method="post" action="discussion-proof.php" name="myform">
 <textarea id="statuspost" name="status" cols="31" rows="6"/>
 Fight for what's right with up to 210 bytes...</textarea>

 <input type="text" id="tag" name="tag" onclick="clear_box()" value="Tag your post!" />
 <input type="submit" class="button" value="Post"/>
</form>

1 个答案:

答案 0 :(得分:0)

要清除所有textareas,请使用$('textarea').val('');代替$("textarea").html(""); 如果您不想清除所有textareas使用您的选择器,例如$('#statuspost').val('');