如何使用jquery在列表视图中的描述之类的文件中动态显示特定标签? [英] How to display the particular tag in a file like description in the listview dynamically using jquery?

查看:96
本文介绍了如何使用jquery在列表视图中的描述之类的文件中动态显示特定标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从诸如some.txt之类的文件中获取一些数据.我想在该文件中显示一些数据,例如列表视图中每个列表下的描述.

I'm trying to get the some data from file like some.txt. I want to display some data in that file like description under the each list in the listview.

$(xml).find('section[order="' + order + '"] content').each(function () {
        var content = $(this).text();
        var seq = order + '' + $(this).attr('order');
        var file = $(this).attr('file');
        $("#content").append('<li><a href="#" data-sequence="s' + seq + '" file="' + file + '">' + content + ' </a> </li> ');
    });
    $("#content").listview('refresh');
});

在上面的代码中我创建了列表视图.现在我将代码更改如下:

In the above code i created the listview.Now I changed the code as below:

$("#content_list").append('<li><a href="#" file="' + file +'">' + content + ' </a><p class="description text"></p> </li> ');


$(".description").each(function() {
        $(".text").load(file, function() {
                var txt = $(this).find('I').text();
                $("#content_list").append('<p>' + txt + '</p>');

            });
 });

在上面的代码中,文件"属性包含一些.txt文件.通过使用此文件,我想获取一些数据以显示文本作为列表中标题的描述.我尝试了多种方法,但整个文件都在显示.

In the above code "file" attribute contains some .txt file. By using this file i want to get some data to display the text as the description for the heading in the list.I tried in many ways but the whole file is displaying.

预先感谢.

推荐答案

您启动了代码.ready,不建议将其与jQuery Mobile一起使用(

You started your code .ready which is not recommended to use with jQuery Mobile (explanation) I replaced it with pageinit which is equivalent to .ready but designed to work with jQuery Mobile.

.load使用不正确;您需要以这种方式从加载的文件中读取检索到的(数据).

.load wasn't used properly; you needed to read retrieved (data) from the loaded file this way.

$('#files').load(file, function (data) {
 var txt = $(data).find('i').text();
 .......
});

这是新的代码.

这篇关于如何使用jquery在列表视图中的描述之类的文件中动态显示特定标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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