开发者

How to use jquery get content with tags in xml

开发者 https://www.devze.com 2023-01-28 04:32 出处:网络
first I have an xml : <app id=\"id-1\"> <html_code> <div id=\"id-1\" class=\"portlet\">

first I have an xml :

<app id="id-1">
    <html_code>
           <div id="id-1" class="portlet">
                  <div class="portlet-header">Links</div>
                  <div class="portlet-content">id-1</div>
           </div>
    </开发者_C百科html_code>
</app>

I want use jquery $.ajax to get the content in tags I use

 $.ajax({
   ……
   success: function (xml) {
          alert($(xml).find("app[id='id-1']").find("html_code").text());
   }

}); 

however, it only alert "links","id-1",but I want the <html_code>'s all content include <div> tags,

so how can I achieve that use jquery ?or I should back to javascript use "getxml"……

thank you:)


You just need to use .html() instead of .text() to get the raw unfiltered goodness, like this:

alert($(xml).find("app[id='id-1']").find("html_code").html());
0

精彩评论

暂无评论...
验证码 换一张
取 消