I’m trying to build a script that counts the number of characters in an anchor tag inside a list item and, if the number of characters is higher than 18, makes the anchor tag narrower so that the text will break. Here’s what I have so far, but it’s not working. Help?
$('nav li a').each(function() {
var curr = this.text().length();
if(curr >= 18){
this.width(50);
}
});
Oh, and for bonus points: is there some way to make the text on the second line indent after the anchor shrinks?
try this instead: