javascript
function changePicPlus(el, pic1, alt1, pic2, alt2) {
if ((el.src).match("images/"+pic1+".jpg")!=null) {
el.src="images/"+pic2+".jpg";
el.alt=alt2;
el.title=alt2;
}
else {
el.src="images/"+pic1+".jpg";
el.alt=alt1;
el.title=alt1;
}
}
window.onload=function() {
var pic=document.getElementById('theDrink');
pic.onclick=function(){changePicPlus(this,'wine','a glass of wine','beer','some beer');}
}
HTML
<h1>Switch img, alt & title onclick</h1>
<p><img id="theDrink" src="images/wine.jpg" alt="a glass of wine"></p>
I wanted to know codes for a comment form like this one
here thanks
Is there any way to do this with links?
Mel,
What do you mean exactly?
The action to change the image is a click. If you had a link, the click would go follow the link.
chua