Document ready initialization
This is the first thing to learn about jQuery: If you want an event to work on your page, you should call it inside the $(document).ready() function. Everything inside it will load as soon as the DOM is loaded and before the page contents are loaded.
<script type="text/javascript"> $(document).ready(function(){ //Do things here }); </script>
The dollar sign ($)
When you see the dollar sign in code, it means the code is interacting with jQuery by calling a jQuery function. So, basically, dollar sign is nothing but it’s an alias for JQuery. Take a look at below jQuery code
jQuery(document).ready(function(){ });
Over here the “jQuery” keyword can be replaced with $ sign.
$(document).ready(function(){ });
Use shorthand for the $(document).ready() event
Instead of writing out the $(document).ready() event:
$(document).ready(function (){ alert('Hey!'); });
… rather use its shorthand version:
$(function (){ alert('Hey!'); });
Redirection
var url = "http://www.grafix.gr"; $(location).attr('href',url);