Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

onclick event "action is not a function"

whenever i make a click on image the console show me "uncaught reference error "

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css">
    <title></title>
</head>
<body>
    <div id="wrap">
      <ul id="menu">
        <li><a href="#" data-icon="&#xe900;">Home</a></li>
        <li><a href="#"data-icon="&#xe91a;">Contact</a></li>
        <li><a href=""data-icon="&#xe90e;">Portfolio</a></li>
        <li><a href="#"data-icon="&#xe971;">About</a></li>
      </ul> 
      <img src="click.png" id="show" onclick ="action()">
    </div>
      <script src="animate.js"></script>
</body>
</html>
function action(){

    alert("working");
}

1 Answer

It seems that your javascript file is not linked on your html. Only the animate.js file is.

animate.js is the same file which i link with html but it directly not calling function from index.html but when i making an click event under .js file it work properly