jQuery Selectors: Selecting elements based on tags

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

In the earlier example, we have used * to select all elements.

We could specify multiple elements separated by comma.

The example here uses $(‘h4, p, a’).  Basically all elements that we could style in the page.

<!DOCTYPE html>
<html>
<head>
    <script src='//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'></script>
    <script>
        $(function () {
            $('h4, p, a').css('color', 'blue');
        });
    </script>
</head>
<body>
<h4>Ushuaia</h4>

<p>Southernmost city in the world.</p>
<a href="http://en.wikipedia.org/wiki/Ushuaia">Visit us here.</a>
</body>
</html>

Series Navigation<< jQuery Selectors: Universal selector *
jQuery Selectors: Class and ID selectors >>