/    Sign up×
Community /Pin to ProfileBookmark

Changing multiple images source

Hi. I’ve got a problem with changing the multiple images source. The code below changes the first image only. What should I do to change the other eight images? Please check this code:

<!DOCTYPE HTML SYSTEM>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-2″>
<title>obrazki</title>
<style type=”text/css”>
.col {
float: left;
width: 33%;
height: 33%;
}
</style>
</head>

<body>

<div class=”col odd”>1<br>
<img id=”asdf” src=”http://pozycjonujemysie.pl/wp-content/uploads/2012/03/wesoly.png” /></div>
<div class=”col even”>2<br>
<img id=”asdf” src=”http://pozycjonujemysie.pl/wp-content/uploads/2012/03/wesoly.png” /></div>
<div class=”col odd”>3<br>
<img id=”asdf” src=”http://pozycjonujemysie.pl/wp-content/uploads/2012/03/wesoly.png” /></div>

<script type=”text/javascript”>
var img = document.getElementById(‘asdf’);
var origSrc = img.src;

var timeout = setTimeout(function(){
img.src = ‘http://pozycjonujemysie.pl/wp-content/uploads/2012/03/wesoly2.png‘;
}, 2000);
</script>

</body>
</html>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@WolfShadeMar 28.2012 — Each object has to have a unique id. You cannot have more than one object with an id of 'asdf'. You CAN, however, have more than one object with the same class.
×

Success!

Help @popiolovy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...