用jquery附加html但没有样式 [英] appending html with jquery but don't get style

查看:107
本文介绍了用jquery附加html但没有样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在网页中添加一些带js的li,为此,我使用了一些jquery移动样式表: 用于加载js,我使用以下代码:

i am adding some li's with js to my webpage, for this li i use some jquery mobile stylesheets: for loading the js i use this code:

$(document).bind('pageshow', function () {
    LoadLaadPalen.init();
}

然后将使用此代码:

var myData = [
    {"Identifier":1,"Naam":"NOT Given","Adres":"Kopenhagen 9","Postcode":"0000LL","Plaats":"NOT Given","Longitude":"0.00000","Latitude":"0.00000"},
    {"Identifier":2,"Naam":"NOT Given","Adres":"NOT Given 1","Postcode":"0000LL","Plaats":"Rotterdam","Longitude":"0.00000","Latitude":"0.00000"},
    {"Identifier":3,"Naam":"NOT Given","Adres":"NOT Given 6","Postcode":"0000LL","Plaats":"Rotterdam","Longitude":"0.00000","Latitude":"0.00000"},
    {"Identifier":4,"Naam":"NOT Given","Adres":"NOT Given 1","Postcode":"0000LL","Plaats":"Den Haag","Longitude":"0.00000","Latitude":"0.00000"},
    {"Identifier":5,"Naam":"NOT Given","Adres":"NOT Given 218","Postcode":"0000LL","Plaats":"Zoetermeer","Longitude":"0.00000","Latitude":"0.00000"}
];

$('.result').append("moi");

var items = [];
$.each(myData, function(index, element) {
    $('.greenfluxlist').append('<a href="#" rel="external"><li id="' + element.Identifier + '"><h3>' + element.Naam + '</h3><p>' + element.Adres +  '</p></li></a>');
});

这必须附加到本节:

<div data-role="content" data-theme="a">
    <div id="laadpalen">
        <p><strong>Op deze locaties zijn laadpunten aanwezig:</strong></p>
        <div class="result">
            <ul class="greenfluxlist" data-role="listview" data-inset="true"></ul>
        </div>
    </div>
</div>

但不幸的是,我看不到任何风格.我只看到带有文本和蓝色标准链接的项目符号.此外,如果我要检查源代码,则没有任何html li代码,但是在网页上我可以看到它们...

But unfortunately I see no style. i only see the bullets with text and a blue standard link.. And also if I am going to check the source code, there aren't any html li code but on the webpage i see them...

推荐答案

查看您的< li>定义.它应以<开头. li>:

Look at your < li> definition. It should start with < li>:

<li><a href="bmw.html">BMW</a></li>

您的格式不正确:

<a href="#" rel="external"><li id="' + element.Identifier + '"><h3>' + element.Naam + '</h3><p>' + element.Adres +  '</p></li></a>

尝试按照我向您展示的方法进行操作:

Try to do it as I showed you:

<li><a class=contact href="#" id="' + data.response[key].id + '" ><h1>' + data.response[key].label + '</h1><p>'+ data.response[key].customer + '</p></a></li>

以<开头li>不带有href:P如果出现问题,请查看以下内容: jQuery文档.记住要触发然后刷新列表:

start with < li> not with href :P In case of problems check this out: jQuery docs. Remember to trigger and then refresh the list:

$('.greenfluxlist').trigger('create');
$('.greenfluxlist').listview('refresh');

这篇关于用jquery附加html但没有样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆