1

I want to display jquery mobile alternate button's with different color. The code which I am using now is only able to change the button theme to 'e' but I want 'theme b'. What can be the problem? Below is the code.

$(document).delegate('[data-role="page"]', 'pagecreate', function(e) {
    var db = openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
    db.transaction(function(tx) {
        tx.executeSql("SELECT id FROM DEMO", [],  

        function(tx, results) {

            var len = results.rows.length,
                i;
            //If no result Found
            for (i = 0; i < len; i++) {
                var test = results.rows.item(i).id % 2; //to get the alternate row's
                if (test == 0) {
                    var id = "color" + results.rows.item(i).id;

                    $("#" + id).attr('data-content-theme', 'e').removeClass('ui-body-d').addClass('ui-body-e').trigger('create'); // Change to theme e
                }
            }
        });
    });
});

I am changing the button theme as per the id of dynamically populated buttons.

4

1 回答 1

0

如果您可以发布一些 HTML 代码,那将有很大帮助。

您可以尝试以下方法,看看是否能解决问题:

$("#" + id).attr('data-content-theme', 'b').removeClass('ui-body-a ui-body-b ui-body-c ui-body-d ui-body -e').addClass('ui-body-b').trigger('create');

于 2012-08-27T17:39:39.193 回答