• Now Online : 63
  • admin@codemyne.net

document ready function:
You might have noticed that all jQuery methods, in our examples, are inside a document.ready() function:

//jQuery functions go here..
This is to prevent any jQuery code from running before the document is finished loading(is ready).
Here are some examples of actions that can fail if functions are run before the document is fully loaded:
  • Trying to hide an element that doesn’t exist
  • Trying to get the size of an image that is not loaded

How to use custom scripts?

It is better to write our custom code in the custom javascript file: custom.js, as follows:

/* file name: custom.js */
alert(“hello world!”);

Now we can include custom.js file in out HTML file as follows:

<title>The jQuery Example</title>
<script type=”text/javascript”
<script type=”text/javascript”
<div id=”newdiv”>
Click on this to see a dialogue box.

Comments/Suggestions are invited. Happy coding......!

Comments Post a Comment