JavaScript - jQuery ???
?? jQuery
JavaScript ?????? ?????? ? ????? ?? ???? ???.
?????? ????? src ??? ?????? URL? ??? <script> ??? ?????.
<!DOCTYPE html>
<html>
<head>
<script src= " http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js">//??? ???
</script>
</head>
<body>
< ;/body>
</html>
jQuery ??
jQuery? ?? ??? $() ??(jQuery ??)???. DOM ??? ? ??? ???? jQuery ??? ??? jQuery ??? ?????.
jQuery? ???? CSS ???? ?? ??? ??? ? ????.
JavaScript??? ? ?? ???? ???? ??? ??? ? ????.
JavaScript ??
function myFunction()
{
var obj=document.getElementById("h01");
obj.innerHTML="Hello jQuery";
}
onload=myFunction;
jQuery ??
function myFunction()
{
???? $("#h01").html("Hello jQuery");
}
$(document).ready (myFunction);
? ??? ??? ???? HTML DOM ?? ??? jQuery: $(document)? ?????.
DOM ??? jQuery? ???? jQuery? HTML DOM ??? ??? jQuery ??? ?????.
jQuery ??? ??? jQuery ??? ????, ? ? Ready()? ??????.
??? JavaScript? ????? myFunction? jQuery? Ready ???? ??? ??? ? ????.
??:
jQuery? ??? DOM ??? ?? jQuery ??? ?????.
jQuery ??? DOM ??? ?? ??? ???? ??? ????.
jQuery ????? HTML DOM ??? ???? ??? ? ????.
?? ??:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script src="http://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script> <script> function myFunction(){ $("#h01").html("Hello jQuery") } $(document).ready(myFunction); </script> </head> <body> <h1 id="h01"></h1> </body> </html>
vs.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script src="http://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script> <script> function myFunction(){ $("#h01").attr("style","color:red").html("Hello jQuery") } $(document).ready(myFunction); </script> </head> <body> <h1 id="h01"></h1> </body> </html>
?? ??? ? ? ??? jQuery? ??(?? ??)? ?????.
?? ??? ??? ??? ?? ?? ??? ???? ??? ?????.