1.使用ip測試網頁伺服器是否正常
ipconfig 鍵入4192.168.1.52於瀏覽器
2.Html檔案儲存於 wamp/www/專案資料夾(自訂名稱)
3.引入JJquery函數庫==至資料夾內
測試
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
</head>
<script language="javascript" src="jquery-1.10.2.js"></script>
<script language="javascript">
$(document).ready(function()
{
alert("Jquery開發環境正常執行");
});
</script>
<body>
</body>
</html>
============
(1)$(tagname) html 指令
$("body");
(2)$("#id")
<a id=a1 href="#">文件</a>
(3)$(.class)
<span class="class">文字</span>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
</head>
<script language="javascript" src="jquery-1.10.2.js"></script>
<script language="javascript">
$(document).ready(function()
{
var $t=$("body").children().length;
alert($t);
});
</script>
<body>
<p>
<span id="sp1">資料庫設計</span>
<span id="sp2">美工設計</span>
</p>
<span id="sp3">程式設計</span>
<ol id="ol">
<li>jsp</li>
<li>php</li>
<li>asp.net</li>
<li>asp</li>
</ol>
</body>
</html>
---------------------
指令用串接方式
text()擷取內容函式
var $t=$("#sp3").next().text();
-----------------------------
var $t=$("#sp3").prev().text();
-------------
var $t=$("#ol li").last().text();
var $t=$("#ol li")first().text();
--------------------
取body內html元件名稱
var $t=$("body").get(0).tagName;例
var $t="";
for (var i=0;i<$("body").children().length;i++)
{
$t +=$("body").children().get(i).tagName+" ";
}
alert($t);
----------------------
children(tagName) 指定要擷取指令內容
var $t=$("body").children("span").text();
---------------------------------------------
1.hover觸發
$("#id").hover(function()
{區塊一},function()
{區塊二});
2.$(this):代表鄭在執行中的元件
3.slideDown(1/1000);
slideUp(1/1000);
4.next(tagName);
往下移動到指定tagName
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
</head>
<script language="javascript" src="jquery-1.10.2.js"></script>
<script language="javascript">
$(document).ready(function()
{
$("div#result").hide();
$("#window").hover(function()
{
$(this).next("div#result").slideDown(200);
},function()
{
$(this).next("div#result").slideUp(200);
});
});
</script>
<body>
<div id="window" style="width:300px; height:20px; background-color:#063">
<font color="#FFCC00">產品展示</font>
</div>
<div id="result" style="width:300px; height:250px; background-color:#063">
<img src="image/a10.jpg" width="300" height="250" />
</div>
</body>
</html>
___________________
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
</head>
<script language="javascript" src="jquery-1.10.2.js"></script>
<script language="javascript">
$(document).ready(function()
{
$("div#result").hide();
$("#window").hover(function()
{
$(this).next("div#result").slideDown(200);
});
$("#a1").click(function()
{
$("div#result").slideUp(200);
});
});
</script>
<body>
<div id="window" style="width:300px; height:20px; background-color:#063">
</div>
<div id="result" style="width:300px; height:250px; background-color:#063">
<a href="javascript:void" id="a1" >關閉</a>
<img src="image/a10.jpg" width="300" height="250" />
</div>
</body>
</html>
-------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
</head>
<script language="javascript" src="jquery-1.10.2.js"></script>
<script language="javascript">
$(document).ready(function()
{
$("div#result").fadeOut();
$("#a1").click(function()
{
$("div#result").fadeIn(200);
});
$("#a2").click(function()
{
$("div#result").fadeOut(200);
});
});
</script>
<body>
<div id="window" style="width:300px; height:20px; background-color:#063">
<font color="#FFCC00">產品展示
<a href="javascript:void" id="a1" >開啟</a>
<a href="javascript:void" id="a2" >關閉</a></font>
</div>
<div id="result" style="width:300px; height:250px; background-color:#063">
<img src="image/a10.jpg" width="300" height="250" />
</div>
</body>
</html>
---------------------------------
jquery css
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
</head>
<script language="javascript" src="jquery-1.10.2.js"></script>
<script language="javascript">
$(document).ready(function()
{
$("ol li").first().css("background","#9966ff");
});
</script>
<body>
<div id="dv1" style="width:200px">
<ol id="ol">
<li>jsp</li>
<li>php</li>
<li>asp.net</li>
</ol>
</div>
</body>
</html>
________________
$("ol li").filter(":contains('php')").css("background","#9966ff");
-----------------------------------
$t ="asp.net";
$("ol li").filter(":contains('"+$t+"')").css("background","#9966ff");
沒有留言:
張貼留言