2015-05-24 139 views
-1

我有以下腳本:jQuery的Get請求返回undefined

$.get("http://www.roblox.com/catalog/", function(onWebsite) { 
    console.log($(onWebsite).find(".name notranslate")[0]) 
}); 

出於某種原因,它返回未定義的,但如果你去指定並執行網頁:document.getElementsByClassName('name notranslate')[0],它將返回什麼,我希望它。我使用正確的語法嗎?

+0

是'notranslate'一個元素? – Satpal

+0

它在頁面上說:(在HTML中)「class =」名稱notranslate「」 –

回答

1

找到具有「名稱」和「notranslate」類的元素。您需要將選擇器編寫在一起,而無需在它們之間存在空格。

因此,使用

$(onWebsite).find(".name.notranslate") 

代替

$(onWebsite).find(".name notranslate") 
+0

謝謝。這工作完美 –

+1

@RobertMaron,因爲你是新的考慮接受答案。請參閱[如何接受答案的工作?](http://meta.stackoverflow.com/questions/5234/how-does-accepting-an-answer-work) – Rimpy