【问题标题】:How to create dynamically div with data-role, data-theme, content-theme, inset, listview?如何使用数据角色、数据主题、内容主题、插图、列表视图动态创建 div?
【发布时间】:2014-04-20 07:35:14
【问题描述】:

如何使用数据角色、数据主题、内容主题、插图、列表视图动态创建 div 使用 jQuery。 我举了一些我尝试过的事情的例子:

    $('<div>').attr('id', 'divCollapsibleset')
                .data('role', 'collapsibleset')
                .data('data-theme', 'e')
                .data('content-theme', 'a')
                .appendTo('#popupNested');

    $('<div>').data('role', 'collapsible')
                .attr('id', 'divCollapsible')
                .data('inset', 'false')
                .appendTo('#divCollapsibleset');

    $('<h3>').addClass('h3-register-items')
                .text('Register')
                .appendTo('#divCollapsible');

    $('<ul>').data('role', 'listview')
                .attr('id', 'listOfItems')
                .appendTo('#divCollapsible');

【问题讨论】:

    标签: jquery css


    【解决方案1】:

    data-role, data-theme, content-theme, inset, listview

    这些也是属性?...也使用 attr()...

    样本

    $('<div>').attr('id', 'divCollapsibleset')
                .attr('data-role', 'collapsibleset')
                .attr('data-theme', 'e')
                .attr('content-theme', 'a')
                .appendTo('#popupNested');
    

    或

    $('<div>').attr({
           'id':            'divCollapsibleset',
           'data-role':     'collapsibleset',
           'data-theme':    'e',
           'content-theme': 'a'
    }).appendTo('#popupNested');
    

    demo

    【讨论】:

    • data('role', value) 与 attr('data-role', value) 不同
    • 如果您有另一个为其运行的脚本...比如主题脚本,请在这些脚本之后运行...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-12
    • 2012-11-10
    • 1970-01-01
    • 1970-01-01
    • 2012-11-18
    • 1970-01-01
    • 2016-11-30
    相关资源
    最近更新 更多