lundi 7 août 2017

Can't understand why my Javascript functions don't work?

I am trying to use some simple Javascript functions to change an 's source to another picture when a button is pressed.

However, none of the buttons seem to work, not even the last one I made just to test whether I would get an alert.

I have tried figuring out what's wrong but I can't seem to find it. I have already searched similar questions and threads but the solution never applied to my case...

Thank you. (I only posted the tags because there's nothing special in the and co. tags)

 <body>

<script type="text/javascript">

function myFunctionMice() {
    document.getElementById("target").src = "http://ift.tt/2vdDj0D">;
};

function myFunctionLaser() {
    document.getElementById("target").src = "http://ift.tt/2vdDj0D" >;
};

function myFunctionBirds() {
    document.getElementById("target").src = "http://ift.tt/2vwp8Gi">;
};


function myTry() {
    alert("example");
};


</script>


<h1 align="center">Web4Cats</h1>

<nav>

                <button type="button" onclick="myFunctionBirds()">Birds</button>
                <button type="button" onclick="myFunctionMice()">Mice</button>
                <button type="button" onclick="myFunctionLaser()">Laser</button>

                <button type="button" onclick="myTry()">Try</button>




</nav>



<img id="target" src="http://ift.tt/2vdDj0D">




</body>

Aucun commentaire:

Enregistrer un commentaire