- 1

How to change source attribute

Dom

5th Jun 2021, 8:10 AM
Joshua Frimpong
Joshua Frimpong - avatar
10 ответов
0
Var arr = document getElementByTagName (" _ ");for(Var x = O;x <arr._;x++){ arr[x]._="demo.jpg";
5th Jun 2021, 8:46 AM
Joshua Frimpong
Joshua Frimpong - avatar
+ 1
Well just change the link?
5th Jun 2021, 8:12 AM
Eashan Morajkar
Eashan Morajkar - avatar
+ 1
You mean in DOM?
5th Jun 2021, 8:14 AM
Eashan Morajkar
Eashan Morajkar - avatar
+ 1
Yeah
5th Jun 2021, 8:14 AM
Joshua Frimpong
Joshua Frimpong - avatar
+ 1
if you want reference then see the javascript changing element in DOM
5th Jun 2021, 8:18 AM
Eashan Morajkar
Eashan Morajkar - avatar
+ 1
var arr = document.getElementsByTagName("img"); for(var x=0; x<arr.length; x++) { arr[x].src= "demo.jpg"; }
8th Dec 2021, 9:06 PM
Roganda Dimas Ariza
Roganda Dimas Ariza - avatar
0
How
5th Jun 2021, 8:13 AM
Joshua Frimpong
Joshua Frimpong - avatar
0
First you have to give an id to the tag then make an object to it and then you can change the source link for example if i have an id called "link" then var changed = document.getElementById("link") changed.src = "some_other_link"
5th Jun 2021, 8:18 AM
Eashan Morajkar
Eashan Morajkar - avatar
0
Changing it by tag name
5th Jun 2021, 8:19 AM
Joshua Frimpong
Joshua Frimpong - avatar
0
Then var changed = document.getElementByTag("Tag") changed.src = "some_other_link" Use this only when there is only one type if that tag
5th Jun 2021, 8:21 AM
Eashan Morajkar
Eashan Morajkar - avatar