jquery - 更改 jquerymobile 上的自定义导航栏图标

标签 jquery jquery-mobile

尚未找到更改具有多个页脚的页面上的自定义导航栏图标的解决方案。

这就是我目前使用的:

    $(".live_menu .ui-icon").css("background","url(/btn_on.gif) !important");
    $(".live_menu .ui-icon").css("background-repeat","no-repeat !important");   

有什么想法吗?

最佳答案

相关:

实例:

Custom Icons

To use custom icons, specify a data-icon value that has a unique name like myapp-email and the button plugin will generate a class by prefixing ui-icon- to the data-icon value and apply it to the button. You can then write a CSS rule that targets the ui-icon-myapp-email class to specify the icon background source. To maintain visual consistency, create a white icon 18x18 pixels saved as a PNG-8 with alpha transparency.

JS:

$('#custom-li-1').click(function() {
    $(this).attr('data-icon','star');
    $(this).children().children().next().removeClass('ui-icon-custom').addClass('ui-icon-star');
}).page();

$('#custom-li-2').click(function() {
    $(this).attr('data-icon','home');
    $(this).children().children().next().removeClass('ui-icon-grid').addClass('ui-icon-home');
}).page();

$('#custom-li-3').click(function() {
    $(this).attr('data-icon','grid');
    $(this).children().children().next().removeClass('ui-icon-star').addClass('ui-icon-grid');
}).page();

HTML:

<div data-role="page" id="home">
    <div data-role="header" data-theme="b">
        <h1>Test</h1>
    </div>
    <div data-role="content" data-theme="d">
        <div data-role="navbar" data-theme="d">
            <ul id="custom-nav-list">
                <li><a href="#" data-icon="custom" class="ui-btn-active" id="custom-li-1">Home</a></li>
                <li><a href="#" data-icon="grid" id="custom-li-2">Second page</a></li>
                <li><a href="#" data-icon="star" id="custom-li-3">Third page</a></li>
            </ul>
        </div>
    </div>
       
</div>

关于jquery - 更改 jquerymobile 上的自定义导航栏图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6902259/

相关文章:

jquery - 更改选项卡jquery的背景颜色

javascript - 移除的 DOM 元素仍然出现在页面上

javascript - 如何制作 HTML 表格数组?

jquery - JQuery Mobile 中的 iFrame 未显示

javascript - 为什么我的 $(selector).index(filter selector) 返回不正确的结果?

javascript - Textillate CSS 动画不能完全与 jQuery Mobile 配合使用

jquery - 我在使用 JQUERY MOBILE 时遇到 .focus() 问题

javascript - 通过key查找json的索引号

javascript - X-editable:如何向输入框添加额外的属性?

javascript - 如何从 JSON 数组中获取数据并将其放入 ListView 中?