Definition
The basic syntax is:$ (Selector). Action ()
Dollar sign defines jquery
Selector: "query" and "Search" HTML elements
Jquery action () executes operations on Elements
Use
1. Get the src attribute of IMG
<SCRIPT src = "jquery/jquery-1.9.1.js" type = "text/JavaScript"> </SCRIPT> // call the jquery File
<SCRIPT type = "text/JavaScript">
Function AAA (){
$ (Document). Ready (function (){
Alert ($ ('# img1'). ATTR ('src '));
})
}
</SCRIPT>
<Input id = "button1" type = "button" value = "standalone" onclick = "AAA ()"/>
2. Various Effects
<Style type = "text/CSS">
. AAA
{
Height: 300px;
Position: absolute;
}
</Style>
<SCRIPT src = "jquery/jquery-1.9.1.js" type = "text/JavaScript"> </SCRIPT>
<SCRIPT type = "text/JavaScript">
Function setyangshi (){
$ (Function (){
(('{Img1'{.css ('width', '200px ');
$ ('# Img1'). addclass ('aaa ');
})
}
$ (Function (){
$ ('# Button1'). Click (function () {// manually add the click Method to the button
$ ('# Img1'). Show (2000); // display
})
$ ('# Button2'). Click (function (){
$ ('# Img1'). Hide (2000); // hide
})
$ ('# Button3'). Click (function (){
$ ('# Img1'). fadein (2000); // fade in
})
$ ('# Button4'). Click (function (){
$ ('# Img1'). fadeout (2000); // fade out
})
$ ('# Button6'). Click (function (){
$ ('# Img1'). animate ({left: '250px '}, 5000); // if the image has a position: absolute
})
})
</SCRIPT>
<Input id = "button5" type = "button" value = "set style" onclick = "setyangshi ()"/>
<Input id = "button1" type = "button" value = "display"/>
<Input id = "button2" type = "button" value = ""/>
<Input id = "button3" type = "button" value = "Fade in"/>
<Input id = "button4" type = "button" value = "Fade Out"/>
<Input id = "button6" type = "button" value = "slide"/>