如何获取内容从Listview Jquery到div的外部链接

时间:2014-06-05 07:09:08

标签: javascript jquery html

[问题]:我无法获得 div = contentlink 表单列表视图Jquery的内容外部链接。此代码如下:(或查看:http://jsfiddle.net/z36UK/2/

<div id="wrap">
  <ul data-role="listview" data-filter="true" data-filter-placeholder="Search..." id="ds-canho">
  </ul>
</div>

<script>
  $(document).ready(function() {

    $.mobile.loading( "show" );
    $.ajax({
      type: "GET",
      url: 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%27http://saigonpearl.info/home/notype/-0-trang-chu.html%27%20and%20xpath%3D%22%2F%2Fdiv%5B%40class%3D%27tindang%27%5D%22&diagnostics=true',
      dataType: "xml",
      success: parseXml
    });

    function parseXml(xml) {
      $(xml).find("div.tindang").each(function() {
        var url = $(this).find('a').attr("href"),
            urlx= url.replace('#menutop','');

        //find each instance of loc in xml file and wrap it in a link
        $("ul#ds-canho").append('<li><a href='+ urlx +'>' + $(this).find('h3').text() + '</a></li>');
        $('ul#ds-canho').listview('refresh');
        console.log( this );
        $.mobile.loading( "hide" );
      });
    }
  });



</script></body>

0 个答案:

没有答案