Skip to content

Instantly share code, notes, and snippets.

@ravinsharma12345
Created August 17, 2013 05:07
Show Gist options
  • Save ravinsharma12345/6255375 to your computer and use it in GitHub Desktop.
Save ravinsharma12345/6255375 to your computer and use it in GitHub Desktop.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Jquery Welcome</title>
<script type="text/javscript" src="http://codeorigin.jquery.com/jquery-2.0.3.min.js"></script>
<script type="text/javscript">
//before we go further, jquery has certain types of material it can manipulate.
//this materials are virtual types, enhanced pseudo-types, function types
// htmlString
// ----------
// in html it look like this <tag>, in jQuery its like this $("<tag></tag>");
// ex, <body>hello</body> => $("<body>hello</body>")
// prototype
// ---------
// in javscript its like this jQuery.prototype, in jQuery its like this jQuery.fn, which is an alias
// Loop
// ----------
// in javscript its like this foreach(var value in sample){};, in jQuery its jQuery.each(sample, function(index, value){});
// Function
// ------------------
// in javascipt its like this function(){}
// in jQuery its like this,
// $(document).ready(function(){});
// $("a").click(function(){});
// $.ajax({
// url: "someurl.php",
// success: function(){}
// });
// Argument
// ---------
// Javascript does not have this
// argument.callee the function that contains it, argument.length is the used for pseudo array
// Context
// --------
// Javascript has "this" to refer to the current context, in JQuery context is refered using the element
// ex, $(document).ready(function{}); refer to window.document
// ex, $("a").click(function(){}) refer anchor DOM element
//
// we can ask what context we are in
// functions scope(){
// console.log( this, arguments.length )
// }
// scope(); context is window, length = 0
// scope.call("foobar", [1, 2]); forcing the context to be foobar, and length is 1 , call is used for
</script>
<script type="text/javascript">
$("body").ready(){
$("a").click(function(){
event.preventDefault;
alert("Hello asshole");
});
$("a").click(function(){
event.preventDefault;
("a").addClass("tag");
})
//DOM manipulation and traversing
//html string
//element
//array
//jquery
};
</script>
<style type="text/css">
a.test{
font-weight: bold;
}
</style>
</head>
<body>
<a href="http://google.com">
hello
</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment