Just a shot into the dark:
$('div.info-box').on('<your action>', function(){
if ($(this).val().length > 50)
{
alert('more than 50 characters');
}
})
You should read more at jquery.com.
Question
I'm brand new to JQuery but have some JS experience. Have inherited someone else's piece of work.
I'm trying to work out the character length of a div and then display a message if there's too many characters.
"selector":"div.info-box",
"filter": function(index,obj){
var boxlength = obj.text().length;
if(boxlength > 50){
return true;
}
return false;
},
"each":function(obj){
$(obj).css("border-bottom","dashed 1px red");
The filter is giving me issues. If I remove the filter entirely then the specific div I want with a class of infobox is highlighted with a red dash (at least I know I have the selector correct). How do I write the filter to detect more than 50 characters? I need to retain the format of selector, filter, each.
Thankyou
La solution
Just a shot into the dark:
$('div.info-box').on('<your action>', function(){
if ($(this).val().length > 50)
{
alert('more than 50 characters');
}
})
You should read more at jquery.com.