简体   繁体   中英

How to create dynamically div with data-role, data-theme, content-theme, inset, listview?

How to create dynamically div with data-role, data-theme, content-theme, inset, listview using JQuery. I'm putting some examples of things I've tried doing:

    $('<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');

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

these are also attributes?... use also attr()...

sample

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

or

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

demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM