I'm trying to make a function in javascript and pass in the parameter "name", then when the user clicks on a photo, an alert will say something like "this photo was taken in ____"
<img src="photos/PhotoVersailles.jpg" onclick="photoWhere(Versailles)" style="width:100%">
<script type="text/javascript">
function photoWhere(name)
{
alert("This photo was taken in "+name+".");
}
</script>
Why isn't my attempt working?
onclick="photoWhere(Versailles)"should be:onclick="photoWhere('Versailles')"onclick="photoWhere('Versailles')"you forgot to wrapVersaillesin quotes.