我的代码:
function wordCount()
{
if ($("#id_COMMENT_PRO).val() == "What did you like about the product?") {
// do not subtract from count
}
if ($("#id_COMMENT_NEG).val() == "What didn't you like about the product?) {
// do not subtract from count
}
var num = 100 - $("#id_COMMENT_PRO").val().length - $("#id_COMMENT_NEG").val().length;
if (num < 0) {
num = 0;
}
$('#count').text('Words left: ' + num);
}
该函数从两个文本区域计数,但我需要它来排除默认文本,我开始编写 IF 语句,但我想不出一种方法来阻止它计数。