选择没有jQuery的元素 [英] Selecting elements without jQuery
本文介绍了选择没有jQuery的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想这会被拒绝,因为它不包含足够的jQuery,但在这里它是:)
I guess this will be voted down, as it doesn't contain enough jQuery, but here it goes :)
什么是最有效的方法来获得下面的jQuery选择器使用普通的旧 javascript返回的元素?
What is the most effective way to get the element(s) returned by the jQuery selector below using plain old javascript?
$('a[title="some title text here"]', top.document)
推荐答案
不确定它是否最有效,但至少它有效。
Not sure if it’s the most effective, but at least it works.
var links = top.document.getElementsByTagName('a');
var result = [];
var linkcount = links.length;
for ( var i = 0; i < linkcount; i++) {
if (links[i].getAttribute('title') === 'some title text here') {
result.push(links[i]);
}
}
这篇关于选择没有jQuery的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文