jQuery Selectors: Selects elements that have some content-parent

This entry is part 17 of 33 in the series jQuery Selectors


This is the inverse of :empty where it selects elements that have at least some content.

<!DOCTYPE html>
    <script src='//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'></script>
        $(function () {
            $('p:parent').css('color', 'blue');

    <p>Southernmost city in the world.</p>

    <p>The city centered around a prison built by the Argentine government.</p>

    <p>They also built a railway to the settlement, now a tourist attraction known as the End of the World Train.</p>

    <a href='http://en.wikipedia.org/wiki/Ushuaia'>Visit us here.</a>

Series Navigation<< jQuery Selectors: Selects elements that have no content
jQuery Selectors: Selecting an element with an ancestor >>

Leave a comment

Leave a Reply