$ ("label name")//Fetch HTML element document.getElementsByTagName ("")
$ ("#id")//Fetch single control document.getElementById ("")
$ ("div #id")//Fetch controls in a control
$ ("#id #id")//control by control ID
$ ("label. Class style name")//Use class to fetch control
$ ("#id"). Val (); Take value
$ ("#id"). Val (""); assigning values
$ ("#id"). Hide (); Hide
$ ("#id"). Show (); Show
$ ("#id"). Text (); Equivalent to taking innerHTML
$ ("#id"). Text (""); Equivalent to Innerhtml= ""
$ ("#id"). CSS Tutorial ("Properties", "value")//Add CSS Styles
$ ("form# form ID"). Find ("#所找控件id"). End ()//traverse the form
$ ("#id"). Load ("*.html")//Load a file
For example:
$ ("Form#frmmain"). Find ("#ne"). CSS ("Border", "1px solid #0f0"). End ()/() return form
. Find ("#chenes"). CSS ("Border-top", "3px dotted #00f"). End ()
$.ajax ({url: "result.asp tutorial X",//URL of the data request page
Type: ' Get ',//data transfer mode (GET or POST)
DataType: "HTML",//expecting data to be returned in data format (e.g. "XML", "HTML", "script", or "JSON")
Data: "Chen=h",///pass parameter string for the datum, only for Get way
timeout:3000,//Set time delay request
Success:function (MSG)//Trigger function when request is successful
{
$ ("#stats"). Text (msg);
},
Error:function (MSG)//functions that are triggered when a request fails
{
$ ("#stats"). Text (msg);
}
});
$ (document). Ready (function () {});
$ ("#description"). Mouseo Tutorial ver (function () {});
Ajax methods
$.get ("result.aspx",//URL of the data request page
{chen: "Test", Age: "25"},///pass parameter string of data
function (data) {alert ("Data loaded:" + data);} The function after the trigger
);
});
});
Get the selected value of the dropdown menu
$ (#testselect option:selected '). Text (); Fetching text values
or $ ("#testselect"). Find (' option:selected '). Text ();
or $ ("#testselect"). Val ();
------
Summary of common function methods in jquery
Event handling
Ready (FN)
Code:
$ (document). Ready (function () {
Your code here ...
});
Role: It can greatly improve the response speed of Web applications. By using this method, you can immediately call the function you are binding when DOM loading is ready to be read and manipulated, and 99.99% of Web page effects functions need to be executed at that moment.
Bind (TYPE,[DATA],FN)
Code:
$ ("P"). Bind ("click", Function () {
Alert ($ (this). text ());
});
Function: Bind an event handler function to a specific event (like click) for each matching element. Play the role of event monitoring.
Toggle (FN,FN)
Code:
$ ("TD"). Toggle (
function () {
$ (this). AddClass ("selected");
},
function () {
$ (this). Removeclass ("selected");
}
);
function: Switch the functions you want to call each time you click. If a matching element is clicked, the first specified function is triggered, and when the same element is clicked again, the specified second function is triggered. A very interesting function that may be used when implementing certain functions dynamically.
(Like click (), focus (), KeyDown () such events are not mentioned here, those are more commonly used in development. )