My HTML file:
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" />
<script src="script.js" type="text/javascript"></script>
</head>
<body>
<form name="someForm">
<input type="button" value="Click me" onClick="myFunction()" />
</form>
<div id="result"></div>
</body>
</html>
My script.js file:
function myFunction(){
$("#result").html("BUTTON WORKS");
}
I have Firebug, and whenever I click the button, Firebug throws me this error:
ReferenceError: myFunction is not defined
What am I doing wrong?
I solved the problem by combining answers from @Susbanth, @MBO, and @dystroy.
Here’s my new HTML file:
I added “http” to the jQuery source, closed the tag, and removed the ‘onClick’ from inside the HTML.
Here’s the updated script.js file:
I made the onClick event a jQuery event.