Javascript Greasemonkey不能使用jQuery';什么是全功率?
我正在尝试使用jQuery查找元素,但它不起作用。。我发现这种选择器在Greasemonkey中是做不到的:Javascript Greasemonkey不能使用jQuery';什么是全功率?,javascript,jquery,greasemonkey,Javascript,Jquery,Greasemonkey,我正在尝试使用jQuery查找元素,但它不起作用。。我发现这种选择器在Greasemonkey中是做不到的: ($("#app7019261521_hover_container > [id^=app7019261521_the_coin]")) 请帮我翻译成原始Javascript。这种选择器是Javascript中的核心。请帮帮我Javascript大师 这应该可以做到,现在我想起了我为什么开始使用jQuery: var children = document.getElementB
($("#app7019261521_hover_container > [id^=app7019261521_the_coin]"))
请帮我翻译成原始Javascript。这种选择器是Javascript中的核心。请帮帮我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);
}
}
var children=document.getElementById('app7019261521\u hover\u container').childNodes;
var-id=[]//存储所有匹配元素的ID
对于(变量i=0;i
由于您的目标是直接针对Firefox,因此您可能需要查看在上实现的功能
检查功能:
var elements = document.querySelectorAll("#app7019261521_hover_container > [id^=app7019261521_the_coin]")
如果这能奏效,我会感到惊讶。如果jQuery不起作用,那么这也不应该,毕竟,在功能强大的浏览器中,jQuery(Sizzle)使用document.querySelectorAll…这在GreaseMonkey中对我很有效。