0

I have been trying this for a while now and have reached the point where I am missing something very simple but just cannot see it now, so any help would be appreciated! I have 2 thumbnails with id "one" and "two" and I would like to use them to change the main img on the page.

<script type="text/javascript">
            //<![CDATA[ 
                window.onload= function(){
                var mainImg= document.getElementByID('ci');

                document.getElementByID('one').onclick= function(){
                mainImg.src='burningbush.png';
                //alert('one clicked');
                };
                document.getElementByID('two').onclick = function(){
                mainImg.src='burningbush.png';
                //alert('two clicked');
                }
                };//]]>
</script>


<div id="mainContainer">
                    <div id="image">
                        <img src="images/home.jpg" id="ci" alt="" />
                    </div>
                    <div id="thumbnail">
                        <img id="one" src="burningbush.png"</img>
                        <img id="two" src="burningbush.png"</img>
                    </div>

                </div>
4

1 回答 1

1

该函数被调用

getElementById

不是

getElementByID

改变它,一切都会奏效

于 2013-08-09T11:13:46.680 回答