troubleshooting Question

Jquery: character length exceeds max for each children then apply style

Avatar of jeremyll
jeremyll asked on
JavaScriptWeb DevelopmentAJAX
3 Comments1 Solution509 ViewsLast Modified:
<ul class="item">
                                <li class=""><a href="#">Apples</a></li>
                                <li class="active"><a href="#">Grapefruit and Durian</a></li>
                                <li class=""><a href="#">Bananas</a></li>
</ul>

Based on the list above, I would like to use jquery to apply a red 1px border around the <li> where its anchors have values that have character length more than 10. In this case, a red border should appear around the "Grapefruit and Durian" item, while the other two items remain the same.

I tried to use something like this:
//    if ($('ul.item li a').children().length > 10) {
//        // do something
//        $('ul.item li').css("border", "3px double red");
//    }
 
 
    if ($('ul.item li').children().value.length > 10) {
        // do something
        $('ul.item li').css("border", "3px double red");
    }
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros