jQuery UI & Menu: Menu with icons

This entry is part 2 of 2 in the series jQuery UI Menu

jQuery UI Menu – Icons

A menu with the default configuration, showing how to use a menu with icons.

<!doctype html>
<html lang='en'>
<head>
    <meta charset='utf-8'>
    <title>jQuery UI Menu - Icons</title>
    <link rel='stylesheet' href='//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css'>
    <script src='//code.jquery.com/jquery-1.10.2.js'></script>
    <script src='//code.jquery.com/ui/1.10.4/jquery-ui.js'></script>
    <link rel='stylesheet' href='https://codecrawl.com/code/jqueryui/jqueryui_style.css'>
    <script>
        $(function () {
            $('#menu').menu();
        });
    </script>
    <style>
        .ui-menu {
            width: 150px;
        }
    </style>
</head>
<body>

<ul id='menu'>
    <li><a href='#'><span class='ui-icon ui-icon-disk'></span>Save</a></li>
    <li><a href='#'><span class='ui-icon ui-icon-zoomin'></span>Zoom In</a></li>
    <li><a href='#'><span class='ui-icon ui-icon-zoomout'></span>Zoom Out</a></li>
    <li class='ui-state-disabled'><a href='#'><span class='ui-icon ui-icon-print'></span>Print...</a></li>
    <li>
        <a href='#'>Playback</a>
        <ul>
            <li><a href='#'><span class='ui-icon ui-icon-seek-start'></span>Prev</a></li>
            <li><a href='#'><span class='ui-icon ui-icon-stop'></span>Stop</a></li>
            <li><a href='#'><span class='ui-icon ui-icon-play'></span>Play</a></li>
            <li><a href='#'><span class='ui-icon ui-icon-seek-end'></span>Next</a></li>
        </ul>
    </li>
</ul>

</body>
</html>
Try The Code

jQuery UI & Button: Buttons with Icons

This entry is part 5 of 5 in the series jQuery UI Button

jQuery UI Button – Icons

Here are some buttons with various combinations of text and icons.

<!doctype html>
<html lang='en'>
<head>
    <meta charset='utf-8'>
    <title>jQuery UI Button - Icons</title>
    <link rel='stylesheet' href='//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css'>
    <script src='//code.jquery.com/jquery-1.9.1.js'></script>
    <script src='//code.jquery.com/ui/1.10.4/jquery-ui.js'></script>
    <link rel='stylesheet' href='https://codecrawl.com/code/jqueryui/jqueryui_style.css'>
    <script>
        $(function () {
            $('button:first').button({
                icons: {
                    primary: 'ui-icon-locked'
                },
                text: false
            }).next().button({
                icons: {
                    primary: 'ui-icon-locked'
                }
            }).next().button({
                icons: {
                    primary: 'ui-icon-gear',
                    secondary: 'ui-icon-triangle-1-s'
                }
            }).next().button({
                icons: {
                    primary: 'ui-icon-gear',
                    secondary: 'ui-icon-triangle-1-s'
                },
                text: false
            });
        });
    </script>
</head>
<body>

<button>Button with icon only</button>
<button>Button with icon on the left</button>
<button>Button with two icons</button>
<button>Button with two icons and no text</button>

</body>
</html>
Try The Code

jQuery UI & Accordion: Customize Icons

This entry is part 5 of 7 in the series jQuery UI Accordion

jQuery UI Accordion – Customize icons

Customize the header icons with the icons option, which accepts classes for the header’s default and active (open) state.

Use any class from the UI CSS framework, or create custom classes with background images.

<!doctype html>
<html lang='en'>
<head>
    <meta charset='utf-8'>
    <title>jQuery UI Accordion - Customize icons</title>
    <link rel='stylesheet' href='//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css'>
    <script src='//code.jquery.com/jquery-1.9.1.js'></script>
    <script src='//code.jquery.com/ui/1.10.4/jquery-ui.js'></script>
    <link rel='stylesheet' href='https://codecrawl.com/code/jqueryui/jqueryui_style.css'>
    <script>
        $(function () {
            var icons = {
                header: 'ui-icon-circle-arrow-e',
                activeHeader: 'ui-icon-circle-arrow-s'
            };
            $('#accordion').accordion({
                icons: icons
            });
            $('#toggle').button().click(function () {
                if ($('#accordion').accordion('option', 'icons')) {
                    $('#accordion').accordion('option', 'icons', null);
                } else {
                    $('#accordion').accordion('option', 'icons', icons);
                }
            });
        });
    </script>
</head>
<body>

<div id='accordion'>
    <h3>Section 1</h3>

    <div>
        <p>Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus,
            molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra
            leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.</p>
    </div>
    <h3>Section 2</h3>

    <div>
        <p>Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at
            aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam.
            In suscipit faucibus urna. </p>
    </div>
    <h3>Section 3</h3>

    <div>
        <p>Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in
            massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna
            quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui. </p>
        <ul>
            <li>List item one</li>
            <li>List item two</li>
            <li>List item three</li>
        </ul>
    </div>
    <h3>Section 4</h3>

    <div>
        <p>Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
            Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
            mauris vel est. </p>

        <p>Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad
            litora torquent per conubia nostra, per inceptos himenaeos. </p>
    </div>
</div>

<button id='toggle'>Toggle icons</button>

</body>
</html>
Try The Code

In this example, we define the right arrow and down arrow by using:

header: 'ui-icon-circle-arrow-e',
activeHeader: 'ui-icon-circle-arrow-s'

jQuery Mobile: List items with icons

This entry is part 49 of 73 in the series jQuery Mobile

To use standard 16×16 pixel icons in list items, add the class of ui-li-icon to the image element and insert 16×16 icons as img tags inside the list items.

<!DOCTYPE html>
<html>
<head>
    <link href='http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.css' rel='stylesheet'/>
    <script src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
    <script src='http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.js'></script>
    <title>Codecrawl</title>
</head>
<body>
<div data-role='page'>
    <div data-role='header'><h1>Count Bubbles On List</h1></div>
    <ul data-role='listview' data-inset='true'>
        <li><a href='#'><img src='https://codecrawl.com/code/flag/gf.png' alt='France' class='ui-li-icon ui-corner-none'>France</a></li>
        <li><a href='#'><img src='https://codecrawl.com/code/flag/de.png' alt='Germany' class='ui-li-icon'>Germany</a></li>
        <li><a href='#'><img src='https://codecrawl.com/code/flag/gb.png' alt='Great Britain' class='ui-li-icon'>Great Britain</a></li>
        <li><a href='#'><img src='https://codecrawl.com/code/flag/fi.png' alt='Finland' class='ui-li-icon'>Finland</a></li>
        <li><a href='#'><img src='https://codecrawl.com/code/flag/us.png' alt='United States' class='ui-li-icon ui-corner-none'>United States</a></li>
    </ul>

    <div data-role='footer' data-position='fixed'>
        <h1>Footer</h1>
    </div>
</div>
</body>
</html>
Try The Code

In the img tag above, I have added class=’ui-li-icon’, a class that is designed for list items.

.
List Item Icons Output

jQuery Mobile: Icon sets

This entry is part 46 of 73 in the series jQuery Mobile

A set of built-in icons in jQuery Mobile can be applied to buttons, collapsibles, listview buttons and more. There is a SVG and a PNG image of each icon.

Icon Sets
<!DOCTYPE html>
<html>
<head>
    <link href='http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.css' rel='stylesheet'/>
    <script src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
    <script src='http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.js'></script>
    <title>Codecrawl</title>
</head>
<body>
<div data-role='page'>
    <div data-role='header'><h1>Button Icons</h1></div>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-action">action</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-alert">alert</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-arrow-d">arrow-d</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-arrow-d-l">arrow-d-l</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-arrow-d-r">arrow-d-r</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-arrow-l">arrow-l</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-arrow-r">arrow-r</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-arrow-u">arrow-u</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-arrow-u-l">arrow-u-l</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-arrow-u-r">arrow-u-r</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-audio">audio</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-back">back</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-bars">bars</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-bullets">bullets</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-calendar">calendar</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-camera">camera</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-carat-d">carat-d</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-carat-l">carat-l</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-carat-r">carat-r</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-carat-u">carat-u</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-check">check</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-clock">clock</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-cloud">cloud</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-comment">comment</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-delete">delete</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-edit">edit</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-eye">eye</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-forbidden">forbidden</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-forward">forward</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-gear">gear</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-grid">grid</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-heart">heart</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-home">home</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-info">info</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-location">location</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-lock">lock</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-mail">mail</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-minus">minus</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-navigation">navigation</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-phone">phone</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-plus">plus</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-power">power</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-recycle">recycle</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-refresh">refresh</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-search">search</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-shop">shop</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-star">star</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-tag">tag</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-user">user</button>
    <button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-video">video</button>

    <div data-role='footer' data-position='fixed'>
        <h1>Footer</h1>
    </div>
</div>
</body>
</html>
Try The Code