English 中文(简体)
j 物体内的物品选修
原标题:jQuery selector on an item within an object
  • 时间:2009-10-09 02:19:32
  •  标签:

我正试图利用一名有关数据问题的“ j”挑选人,我从“ja”电话回来。

Here is the code I have -

$.ajax({
  url:  moo.html ,
  success: function ( code )
  {
    var divs = $(code).filter(function(){ return $(this).is( div ) });     
    console.log( divs ); // gives me back entire object
    console.log( $(divs[0]) ); // gives me the first object

    // console.log( $(divs[0]).( #bar )); // error
    // console.log( $(divs #foo #bar)); // error
    // console.log( $(divs).(#foo #bar)); // error
  }
});
</script>

moo.html -

<div id= foo ><div id= bar >123</div></div><div id= biz ><div id= dev >345</div></div>

因此,我如何能够在oo干 within中 gr取第html条的内容(123条)。

最佳回答
var bar = $("#bar", $(code)).text();

var bar = $("#bar", $(code)).html();

无论如何,都是适当的。

你们也可以这样处理该问题:

var bar = $(code).find("#bar").text();
问题回答

如果我不理解你的问题,但我认为这应当做到:美元(“#”)。





相关问题
热门标签