<!--
$ is a function, the first is to add $ to the window, then the value is a function, the value returned by the function is the object.
1. jquery Core function
* Abbreviation: jQuery function ($/jquery)
* The JQuery Library is directly exposed to $/jquery
* After the introduction of the jquery library, directly use the $
* When function with: $ (XXX)
* When objects are used: $.xxx ()
2. JQuery Core Objects
* Abbreviation: jquery object
* Get jquery object: The jquery object is returned by executing the jquery function
* Use jquery object: $obj. XXX ()
-
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "UTF-8"> <title>01_ initial jquery</title> <Scripttype= "Text/javascript">window.onload= function() {btn1=document.getElementById ("BTN1"); Btn1.onclick= function(){ varusername=document.getElementById ("username"). Value; Alert (username)}}</Script> <!--using jquery to implement - <Scripttype= "Text/javascript"src=".. /.. /js/jquery-1.10.1.js "></Script> <Scripttype= "Text/javascript"> //1\ using the JQuery core function ($,jquery) //binding Document loading complete listening is just as spicy as Window.onload's effect. $ (function () {}) $(function(){ $("#btn2"). Click (function(){ varusername= $("#username"). Val ();//binding monitoring to BTN2alert (username)}) }) /** JQuery Core Object * Executes $ () object returned * The jquery object will be preceded by a $*/ </Script> </Head> <Body> <!--need: Click "OK" button, prompt for the value of the input -User name:<inputtype= "text"ID= "username" > <ButtonID= "BTN1">Ok (native version)</Button> <ButtonID= "BTN2">Ok (jquery edition)</Button> </Body></HTML>
2 of jquery's weapons