English 中文(简体)
动态编制清单
原标题:Dynamically Creating Lists

我正试图从对我所援引的“非洲复兴开发银行”呼吁的答复中编制一份清单。

格式1:

$.ajax({
    url: "BirthdayInvitations.xml",
    dataType: "xml",
    success: function ParseXml(xml) {
        $("div#menu").append( <ul "data-role="listview">  );
        var ul = $("div#menu  > ul");
        $(xml).find("event").each(function() {
            $(ul).append( <li><a href="  + "hai" +  ">  + this.textContent+  </a></li> ); 
        });
        $( ul ).listview( refresh );
    }
});

形式2:

我甚至尝试了以下格式。

$( ul ).append($( <li/> , {    //here appendin `<li>`
     data-role :"listview"
}).append($( <a/> , {    //here appending `<a>` into `<li>`
     href :  test.html ,
     data-transition :  slide ,
     text :  $(this).textContent 
})));

格式1的结果是固定标签的简单清单。

请帮助我找到解决办法,我需要一份名单,充满活力。

形式2: doesn t work at all.

问题回答

我修改了你的第一个例子。 象<代码>、文本Content等附后的标签问题,请您的XML数据无任何发现,是正确的标签/标语?

$.ajax({
    url: "BirthdayInvitations.xml",
    dataType: "xml",
    success: function(xml) {
        var $ul = $("<ul></ul>").data("role", "listview");
        $(xml).find("event").each(function() {
            $ul.append( <li><a href="  + "hai" +  ">  + this.textContent +  </a></li> ); 
        });
        $ul.appendTo("DIV#menu");
        $ul.listview( refresh );
    }
});

我猜测,由于名单表尚未建立,你第一次需要打上美元名单,而复读只能用连续电话。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签