Change Href And Target Of An Anchor
I've wrote this so it changes the href of the anchor with the class name but I also would like it to change the target, how do I add this? window.onload = function() { var chan
Solution 1:
change[i].setAttribute('target', '_blank');
Solution 2:
Try this
window.onload = function() {
var change = document.getElementsByTagName('a');
for (var i = 0, j =change.length; i < j ; i++) {
if ((' ' + change[i].className + ' ').indexOf(' ' + "smeCls" + ' ') > -1) {
change[i].href = "http://www.google.com";
}
}
}
Post a Comment for "Change Href And Target Of An Anchor"