/    Sign up×
Community /Pin to ProfileBookmark

i need a script that swaps multiple images, in which when i call the function, i type swap(‘../myimg.gif’) to specify which image i want it to change into. also, i need it to change back to the original when a different image is clicked…

i hope you can do this…

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisAug 04.2003 — If you only have one active "swap", jut keep track of that one and then "unswap" it when the next one is "swapped". Something like this:
<i>
</i>var activeImg = null; // first time it will be empty
...
function unSwap() {
document.images[activeImg.name].src = activeImg.src;
}

function swap(nm, src) {
if (activeImg) unSwap();
activeImg = new Image();
activeImg.name = nm; // remember the old state
activeImg.src = document.images[src];
document.images[nm].src = src; // do the swap
}
Copy linkTweet thisAlerts:
@xataku_nakusuteauthorAug 04.2003 — i need multiple images to swap...(at different times)...
×

Success!

Help @xataku_nakusute 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.19,
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,
)...