Hi guys,
I have the html code here:
and the javascript code here:Code:<img id=img src=''> <input type=submit value='Photo A' id=buttonA /> <input type=submit value='Photo B' id=buttonB />
I have problems as in this scenario:Code:img = document.getElementByID('img'); buttonA = document.getElementByID('buttonA'); buttonB = document.getElementByID('buttonB'); function A() { img.src = Photo A.jpg; } function B() { img.src = Photo B.jpg; } buttonA.addEventListener('click', false, A); buttonB.addEventListener('click', false, B);
1. When I hit Button A first, Photo A shows; but then I hit Button B, Photo B does not show.
2. When I hit Button B first, Photo B shows; and then I hit Button A, Photo A shows, but then I hit Button B again the photo remain A and does not change.
How do I switch functions alternately by disabled one other when the other is clicked.
Hope I make myself clear and thanks in advance



Reply With Quote
Bookmarks