Jquery mobile JQuery Mobile动态背景色为';李';

Jquery mobile JQuery Mobile动态背景色为';李';,jquery-mobile,Jquery Mobile,正在尝试设置我的动态li的背景色。由于每个li都需要在代码中指定一种颜色,因此没有为li指定“类”或“id” $(data).find("#HospitalDescriptions").find('th').filter(function(){ if (this.innerHTML !== '') { var bgcolor = $( this ).css( "background-color" ); var txtcolor = $( this ).cs

正在尝试设置我的动态li的背景色。由于每个li都需要在代码中指定一种颜色,因此没有为li指定“类”或“id”

$(data).find("#HospitalDescriptions").find('th').filter(function(){
    if (this.innerHTML !== '') {
        var bgcolor = $( this ).css( "background-color" );
        var txtcolor = $( this ).css( "color" );
        if (bgcolor !== ''){
            $('#information').append('<li><span style="background-color:' + bgcolor + ';color:' + txtcolor + ';">' + this.innerHTML + '</span></li>');
            $('li').css({backgroundColor: bgcolor});
        } else {
            $('#information').append('<li>' + this.innerHTML + '</li>');
        }
        }
    $('#information').listview('refresh');   // not working!
});
$(数据).find(#HospitalDescriptions”).find('th').filter(函数(){
如果(this.innerHTML!=''){
var bgcolor=$(this.css(“背景色”);
var txtcolor=$(this.css(“color”);
如果(bgcolor!=''){
$(“#信息”).append(“
  • ”+this.innerHTML+”
  • ); $('li').css({backgroundColor:bgcolor}); }否则{ $(“#信息”).append(“
  • ”+this.innerHTML+”
  • ); } } $(“#信息”).listview('refresh');//不工作! });
    HTML:

    
    软管集管
    刷新
    问询处
    
    区域一、二、三
    区域四
    区域五
    由CM供电
    我现在得到的结果。文本背景色需要填充列表视图区域,而不是黑色:

    1

    文本对齐:居中;对李也一样。甚至更简单奥马尔昨天

    将这个
    style=“background color:”+bgcolor+”;color:“+txtcolor+”;
    添加到
    li
    而不是
    span
    。我知道它很简单,多亏修复了它……现在我只需要将它居中。
    text align:center;
    也添加到li。甚至更简单。
    <div data-role="page" data-theme="b" id="hospitals" data-add-back-btn="true">
        <div data-role="header">
            <h1>HOSP-HEADER</h1>
            <a class="ui-btn-right" id="infoButton" onclick="$('#locations').listview('refresh');">Refresh</a>
        </div><!-- /header -->
    
        <div data-role="content" data-theme="b" id="regions">   
    
            <div data-role="content">
                <h4>Information</h4>
                <ul data-role="listview" data-inset="true" id="information">
                    <!-- AJAX CONTENT -->
                </ul>
            </div>
    
            <div data-role="collapsible">
                <h4>Regions I, II, III</h4>
                <ul data-role="listview" data-inset="true" id="region3">
                    <!-- AJAX CONTENT -->
                </ul>
            </div>
    
            <div data-role="collapsible">
                <h4>Region IV</h4>
                <ul data-role="listview" data-inset="true" id="region4">
                    <!-- AJAX CONTENT -->
                </ul>
            </div>
    
            <div data-role="collapsible">
                <h4>Region V</h4>
                <ul data-role="listview" data-inset="true" id="region5">
                    <!-- AJAX CONTENT -->
                </ul>
            </div>
    
        </div>
    
        <div data-role="footer">
            <h1>Powered by CM</h1>
        </div><!-- /footer -->
    </div>