我有下載從其他網頁的HTML源代碼:如何訪問jQuery中使用.find()挑選的選擇器的內部html?
$.get
(
'http://example.com/ex.php?something=0',
function(response){someFunction(response)}
);
再有就是它觸發功能:
function someFunction(data)
{
var someArray = [];
$(data).find('.someClass').each(function(loop, item)
{
someArray.push(item);
});
$('tr:eq(1) > td:eq(0)').html(someArray[0]); //yes, I do need all the containers of class none as I'm planning to put each of them in a table cell later
}
到目前爲止,它工作正常,但是卻讓<container class="someClass">some text</container>
到TD我只是想從中提取一些文字放在那裏。
我試圖去與
$('tr:eq(1) > td:eq(0)').html(someArray[0].html());
和
$('tr:eq(1) > td:eq(0)').html(someArray[0].contents());
但無論是作品。我嘗試過谷歌它,但.contents()是我發現的唯一的東西,.html()是我能想到的唯一的東西(通常當我有一個選擇器像這樣選擇$('selector')
方法html()工作)。
我現在明白了;)。我只是不得不像這樣插入$(item)而不是item。非常感謝:D。 – Fiodor