vendredi 30 mai 2014

My jquery event isn't firing?


Vote count:

0




I'm basically trying to implement:



$(function() {
var maxWords = 10;
var wordCounts = {};
$("#a").keyup(function() {
var matches = this.value.match(/\b/g);
wordCounts[this.id] = matches ? matches.length / 2 : 0;
var finalCount = 0;
$.each(wordCounts, function(k, v) {
finalCount += v;
});
$('#finalcount').val('Words: ' + finalCount);
if(finalCount > maxWords){
$("#a").val(a.value.slice(0,-2));
};
}).keyup();
});


HEre's the example Im using: http://ift.tt/1oDhss8


My version is here: http://ift.tt/1oS69ds


For some reason, mine isn't working. I don't really understand jquery or javascript events very well so I'm sure there's something I"m missing, but for the life of me I can't figure out what. What I"m tyring to do is limit the number of words that can go into a textarea box. Any advice> Thank you very much.



asked 41 secs ago






Aucun commentaire:

Enregistrer un commentaire