I'm trying to run a bit of a custom script to add a style class based on the length of the string in a h4 element. Basically, if the h4 is long enough that it takes up 2 lines, I'll want to adjust the CSS so that the h4 with a two line title also lines up with h4's that have a single line title.
A bit of JQuery returns the all the tags an their content..
jQuery(document).ready(function($){
$('div.post-content div.title-info h4 a').text(function(){
console.log(this);
});
});
This returns..
<a href="http://www.theaterunder30.com/farewell-to-amazing-grace/">Farewell to Amazing Grace</a>
<a href="http://www.theaterunder30.com/details-announced-for-harry-potter-and-the-cursed-child/">Details Announced for “Harry Potter and the Cursed Child” </a>
<a href="http://www.theaterunder30.com/another-blog-post/">Another Blog Post</a>
<a href="http://www.theaterunder30.com/arrested-development-quotes/">Arrested Development Quotes</a>
Which is great. But only part of the puzzle. I need to be able to count the characters only within the tags and then use something like .length to determine if it's greater than X amount of characters execute {...}
I'm not sure how I can access the text between the tags? in order to run a .length on it. I've had a look at this post but I honestly can't figure out how to apply it to my situation. Any help or guidance would be awesome.
Thanks for looking!