I thought that I was doing everything right, however I keep getting this error. $(document).ready(); // undefined in the console. I imported my jquery script.
<script src = "//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script >
$(document).ready(function(){
$("div#chat").hide();
});
function send_file(){
}
function remove_selected(){
}
function changeToFile(){
}
function chatToProfile(){
}
function changeToChat(){
}
</script>
$( document ).ready()A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you. Code included inside $( document ).ready() will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute.
Why document ready is deprecated? As of jQuery 3.0, only the first syntax is recommended; the other syntaxes still work but are deprecated. This is because the selection has no bearing on the behavior of the . ready() method, which is inefficient and can lead to incorrect assumptions about the method's behavior.
The ready() method is used to make a function available after the document is loaded. Whatever code you write inside the $(document ). ready() method will run once the page DOM is ready to execute JavaScript code.
As a convention, placing the script element just before the closing body tag makes the script wait for the rest of the document to load before running. We also can make this process faster in jQuery by using the $(document). ready() method. The $(document).
If you're running this file locally (which I suspect you are...), this will attempt to find the referenced file on your local system, which will not be there.
To fix this, instead use this:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With