I have a jQuery statement as;
$("a[target="+iframeId+"]").attr("href", url);
What is the best way to write this in normal Javascript DOM such that 开发者_Go百科the perofrmance is not affected much?
One way to do it, though the jquery method is almost assuredly faster:
var links = document.getElementsByTagName("a");
for (var i = 0; i < links.length; i++) {
if (links[i].getAttribute("target") == iframeId) {
links[i].setAttribute("href", url);
}
}
精彩评论