I have a simple HTML. I am using the JQuery for AJAX purpose. Now, I want to put my javascript function in a separate javascript file. What is the syntax for this? For example, currently my script section in the HTML is something like this:
<script>
<script type="text/javascript" src="scripts/scripts.js"></script>
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type = "text/javascript" language="javascript">
$(document).ready(function() {
$("#SubmitForm").click(Submit());
});
</script>
But I want to put the function
function() {
$("#SubmitForm").click(Submit());
})
in the file scripts.js. Can I use assign a name to that function and refer to it?
EDit: I still have a bit of problem here: I changed the code to
<script type = "text/javascript" language="javascript">
$(document).ready(function() {
$("#SubmitForm").click(submitMe);
});
</script>
and in a separate js file, I have the following code:
var submitMe = function(){
alert('clicked23!');
//$('#Testing').html('news');
};
Here's the body section:
<body>
welcome
<form id="SubmitForm" action="/showcontent" method="POST">
<input type="file" name="vsprojFiles" />
<br/>
<input type="submit" id="SubmitButton"/>
</form>
<div id="Testing">
hi
</div>
</body>
Yet, it is still not working, anything I miss?