This code works when it is included in the HTML file, but I’d rather have it in a separate JS file.
Can that be done?
<script type="text/javascript">
window.onload = function() {
var a = document.getElementById("mylink");
a.onclick = function() {
$('#c').empty();
return false;
}
}
</script>
Update
I have tried this, but doesn’t work…
$(document).ready(function(){
// other functions here
window.onload = function() {
var a = document.getElementById("mylink");
a.onclick = function() {
$('#c').empty();
return false;
}
}
$('form').live('submit', function(){
...
Sure thing – do this in the HTML file:
Then in
/js/yourfile.js:This will work the same way as your code above.