我有 progress.js 文件,其中包含以下代码
$('#text_area_input').keyup(function()
{
var text_area_box =$(this).val();//Get the values in the textarea
var max_numb_of_words = 160;//Set the Maximum Number of characters
var main = text_area_box.length*100;//Multiply the lenght on words x 100
var value= (main / max_numb_of_words);//Divide it by the Max numb of words previously declared
var count= max_numb_of_words - text_area_box.length;//Get Count of remaining characters
if(text_area_box.length <= max_numb_of_words)
{
$('#progressbar').css('background-color','#5fbbde');//Set the background of the progressbar to blue
$('#count').html(count);//Output the count variable previously calculated into the div with id= count
$('#progressbar').animate(//Increase the width of the css property 'width'
{
'width': value+'%'
}, 1);//Increase the
}
else
{
$('#progressbar').css('background-color','yellow');
//If More words is typed into the textarea than the specified limit ,
//Change the progress bar from blue to yellow
var remove_excess_characters =text_area_box.substr(0,max_numb_of_words);
$('#text_area_input').val(remove_excess_characters);
//Remove the excess words using substring
}
return false;
});
});
我必须在我的 php 文件中调用该函数。我怎样才能使它正确?我在我的项目中包含了所有必要的 css