[英]Is Greasemonkey not capable of using jQuery's full power?
我正在嘗試使用jQuery查找元素,但是它不起作用..我發現在Greasemonkey中無法完成這種選擇器:
($("#app7019261521_hover_container > [id^=app7019261521_the_coin]"))
請幫助我將其翻譯成原始Javascript。 這種選擇器是用Java編寫的硬核。 請幫我Javascript專家!
這應該可以做到,現在我記得為什么我開始使用jQuery:
var children = document.getElementById('app7019261521_hover_container').childNodes;
var ids = []; //to store the IDs of all matching elements
for(var i = 0; i < children.length; i++)
{
//indexOf returns zero is subject starts with passed string
if(children.item(i).id.indexOf('app7019261521_the_coin') == 0)
{
alert('Got One!');
ids.push(children.item(i).id);
}
}
由於您直接針對Firefox,因此您可能想看看Firefox 3.5上實現的Selectors API 。
檢查document.querySelectorAll函數:
var elements = document.querySelectorAll("#app7019261521_hover_container > [id^=app7019261521_the_coin]")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.