I have a problem with the
document.ready
.js
Uncaught ReferenceError: scrollWin is not defined
.js
<head>
<head>
<link href="css/main.css" rel="stylesheet">
</head>
<body>
<button onclick="scrollWin()">Click me to scroll</button>
<script src="js/jquery-1.12.3.js"></script>
<script src="js/custom.js"></script>
</body>
// custom.js file
$(document).ready(function() {
function scrollWin() {
window.scrollTo(300, 500);
}
});
define function outside on document.ready
$(document).ready(function() {
});
function scrollWin() {
window.scrollTo(300, 500);
}
OR
$(document).ready(function(){
scrollWin = function ()
{
window.scrollTo(300, 500);
}
});