i'm trying to write a function which counts the number of syllables in a piece of text, i know it won't be that accurate, it's just a simple version I need at the moment which roughly counts the number of syllables.
whenkeydown = function(max_length) {
$("#my_text").unbind().keyup(function() {
//check if the appropriate text area is being typed into
if (document.activeElement.id === "my_text") {
//get the data in the field
var text = $(this).val();
function countSyllables(words) {
console.log(words);
for (var z; z < words.length; z++) {
word = word[z].toLowerCase();
if(word.length <= 3) { return 1; }
word = word.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/, '');
word = word.replace(/^y/, '');
syllables = word.match(/[aeiouy]{1,2}/g).length;
syllableCount += syllabes
}
return syllableCount
}
var syllableCount = countSyllables(text)
$("#noOfSyllables").html("").html(syllableCount).css("color", "#F7860C"); //orange
The error i get in the (aptana/firefox) debugger is "TypeError: $(...).html(...).html(...).css is not a function", does this mean my function does not return anything?