锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
DOM
Attributes
1.attr(key, value)
$("img").attr("title", "xx");
涔熸槸瀵瑰睘鎬х殑娣誨姞浣嗗彲浠ュ姩鎬?br />eg:聽聽聽 鍦ㄦ瘡嬈$粰title鏃?鍔ㄦ佷簡寮濮?br /><img title="pic" /><img title="pic" /><img title="pic" />
閫氳繃$("img").attr("title", function(index) { return this.title + (i + 1); });
<img title="pic1" /><img title="pic2" /><img title="pic3" />
2.聽 html 鍐呭鍙栥佽祴鍊?br />鍙柭犅?lt;div><input/></div>聽 ->>聽聽$("div").html(); ->>聽 緇撴灉錛?lt;input/>
璧嬄?$("div").html("<b>new stuff</b>"); ->><div><b>new stuff</b></div>
閫氳繃榪?ajax 灝卞緢綆鍗曚簡銆俕_^
Manipulation
1.浣嶇疆璋冩崲 after, append銆乥efore
$("p").after("<b>Hello</b>");聽聽聽 <p>鍚?娣誨姞 <b>..
$("p").after( $("#foo")[0] );聽 鎶奿d涓篺oo鐨勬爣絳劇Щ鍔ㄥ埌<p>鍚?br />
$("input[@name='butt1']").clone().prependTo("form"); //clone in form
]]>
1.瀹氫綅 $("p[a]").hide();
$("p:eq(0)").show();
$("div:visible").hide();
$("ul/li")
/* valid too: $("ul > li") */
$("p.foo[a]");
$("input[@name=bar]").val();
$("input[@type=radio][@checked]")
2.浜嬩歡娣誨姞
聽聽 $(document).ready(function()聽{
聽聽聽聽聽聽聽聽 $("a").click(function()聽{聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 $("div").hide(); //璺屼唬涓嶅彲瑙?<a>
聽聽聽聽聽 });
聽聽聽 });
3.欏甸潰 javascript 杈撳叆錛堝拰jsp鐨?out.print(...)錛?b>$(html)
4.鍐檆ss
5.鍖呭惈瀹氫綅
$("div聽>聽p") //瀹氫綅two <p>two</p>
6.鑼冨洿瀹氫綅
聽聽聽聽聽聽聽聽<form>
聽聽聽聽聽聽聽聽聽聽聽聽<input聽type="button"聽value="鍝堝搱"/>
聽聽聽聽聽聽聽聽</form>
</body>
$("input:button",聽document.forms[0])[0].setAttribute("value","google");
鎴?/span>聽 $("div", xml.responseXML) 絳?br />
7.琛ㄨ揪璇曞畾浣?div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;">$("p[@name='p1']").hide();//hide涓嶈聽$(..)[0]
$("input[@name='butt1']:button",聽document.forms[0])[0].setAttribute("value","google");
8.$(..).fun.. 娣誨姞鏂規硶
聽聽聽聽聽聽聽聽聽聽聽聽<input聽name="butt1"聽type="button"聽value="google"/>
聽聽聽聽聽聽聽聽</form>
聽聽聽聽聽聽聽聽<script>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽jQuery.fn.extend({
聽聽聽聽聽聽聽聽聽聽check:聽function()聽{
聽聽聽聽聽聽聽聽聽聽聽聽alert('check');
聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽});
聽聽聽聽聽聽聽聽$("input[@name='butt1']:button",聽document.forms[0]).check();
聽聽聽聽聽聽聽聽</script>
鎴?br />jQuery.extend({
min: function(a, b) { return a < b ? a : b; },
max: function(a, b) { return a > b ? a : b; }
});
9.$.noConflict()
聽聽聽聽聽聽聽聽<form>
聽聽聽聽聽聽聽聽聽聽聽聽<input聽name="butt1"聽type="button"聽value="google"/>
聽聽聽聽聽聽聽聽</form>
聽聽聽聽聽聽聽聽<a聽href="#"聽temp_href="#"聽name="li"聽>Link</a>
聽聽聽聽聽聽聽聽<script>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽var聽$j聽=聽jQuery.noConflict();聽聽
聽聽聽聽聽聽聽
聽聽聽聽聽//聽Use聽jQuery聽via聽$j()聽聽
聽聽聽聽聽$j(document).ready(function(){聽聽
聽聽聽聽聽聽聽聽$("a").click(function()聽{聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽$j(document.forms[0]).hide();聽聽
聽聽聽聽聽聽聽聽聽聽聽});
聽聽聽聽聽});聽
聽聽聽聽聽聽聽聽</script>
聽聽聽聽</body>
10. $ 涓鑸柟娉?br />
$("img").each(function(i){
聽聽this.src聽=聽"test"聽+聽i聽+聽".jpg";
});
<img/><img/>
<img聽src="test0.jpg"/><img聽src="test1.jpg"/>
$("p").eq(1) //鍚?涓?br />$("p").lt(1) //姝e彇 1 寮濮?br />
$("img").get();//鍏ㄥ彇
$("img").get(0); //欏哄簭鍙?0寮濮?br />$("p").gt(0) //鍙嶅彇浠?寮濮?br />
$("*").index( $('#foo')[0] )
<div id="foobar"><b></b><span id="foo"></span></div>
榪斿洖緇撴灉 2
$("img").length; //鎬婚暱搴?br />$("img").size();
]]>
聽聽聽聽聽聽聽聽<script聽type="text/javascript">
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dojo.require("dijit.layout.LayoutContainer");聽聽//浣嶇疆鍜屽畼鏂圭殑鍙嶈繃鏉?IE 灝辨病浜嬩簡 @#$%^!
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dojo.require("dijit.layout.ContentPane");聽聽 // FF娌¤繖闂聽 .榪樻槸FF濂藉晩 澶у鏀寔FF聽聽 ^_^
聽聽聽聽聽</script>
<head>
<title>Layout聽Container聽Demo聽1</title>
聽聽聽聽<style聽type="text/css">
聽聽聽聽聽聽聽聽@import聽"/dojoCharset/js/dojo/dijit/themes/tundra/tundra.css";
聽聽聽聽聽聽聽聽@import聽"/dojoCharset/js/dojo/dojo/dojo.css"
聽聽聽聽</style>
聽聽聽聽聽聽聽聽<script聽type="text/javascript"聽src="/dojoCharset/js/dojo/dojo/dojo.js"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽djConfig="parseOnLoad:聽true"></script>
聽聽聽聽聽聽聽聽<script聽type="text/javascript"聽src="/dojoCharset/js/create/cr.js"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽djConfig="parseOnLoad:聽true"></script>聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽<script聽type="text/javascript">
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dojo.require("dijit.layout.LayoutContainer");
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dojo.require("dijit.layout.ContentPane");
聽聽聽聽聽</script>
</head>
<body聽class="tundra">
<div聽dojoType="dijit.layout.LayoutContainer"聽style="width:聽100%;聽height:聽100%">聽聽聽 //寮涓涓?LayOut 絀洪棿
聽聽聽<div聽dojoType="dijit.layout.ContentPane"聽layoutAlign="top"聽style="background-color:red"聽href="/dojoCharset/html/top.jsp"> //top
聽聽聽聽聽聽聽聽The聽Dojo聽Book
聽聽聽</div>
聽聽聽<div聽聽dojoType="dijit.layout.ContentPane"聽layoutAlign="left"聽 //left
聽聽聽聽聽聽聽聽style="background-color:lightblue;width:聽120px;">
聽聽聽聽聽聽聽聽Table聽of聽Contents
聽聽聽聽</div>
聽聽聽聽<div聽id='div'聽dojoType="dijit.layout.ContentPane"聽layoutAlign="client"聽聽聽聽聽聽聽聽 //client
聽聽聽聽聽聽聽聽style="background-color:yellow">
聽聽聽聽聽聽聽聽聽聽聽聽<blockquote><a聽href="../node/717">Introduction</a>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<ol>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<li><a聽href="../node/718">Dojo:聽What聽is聽It?</a></li>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<li><a聽href="../node/719">History</a></li>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<li><a聽href="../node/733">What聽Dojo聽Gives聽You</a></li>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</ol>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</blockquote>
聽聽聽聽</div>
</div>聽聽聽聽聽聽聽
</body></html>
cr.js聽聽聽聽function聽on()
{
聽聽聽聽聽聽聽function聽helloPressed()
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽window.alert('ok');
聽聽聽聽聽聽聽聽聽聽聽聽dojo.xhrGet(
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽url:聽'/dojoCharset/html/top.jsp',聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽handleAs:聽"text",
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽encoding:聽"utf-8",
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽timeout:聽5000,聽//聽Time聽in聽milliseconds
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽load:聽function(data,聽ioArgs)聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽document.getElementById('div').innerHTML聽=聽data聽;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽});
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽聽聽dojo.addOnLoad(helloPressed);聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽
聽聽聽聽}
top.js
<%@聽page聽contentType="text/html;charset=gb2312"聽%>聽
<html>
聽聽聽聽<head>
聽聽聽聽聽聽聽聽<meta聽http-equiv="Content-Type"聽content="text/html;聽charset=GB2312">聽聽
聽聽聽聽聽聽聽聽<script聽type="text/javascript"
聽聽聽聽聽聽聽聽聽聽聽聽src="/dojoCharset/js/create/cr.js"></script>聽
聽聽聽聽</head>
聽聽聽聽<body>
聽聽聽聽聽聽聽聽<center>
聽聽聽聽聽聽聽聽聽聽聽聽<h3>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<font聽color='darkcyan'>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽澶у濂?br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</font>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<INPUT聽id='butt'聽value="list"聽type="button"聽onclick="on()"/>
聽聽聽聽聽聽聽聽聽聽聽聽</h3>
聽聽聽聽聽聽聽聽</center>
聽聽聽聽</body>
聽聽聽聽
</html>
]]>
聽聽聽榪欓噷鏈変釜闂 html -> html聽聽鐨勪貢鐮侀棶棰樹笉鏄緢濂借В鍐?鍙兘鏄痙ojo 0.9 bug??) 榪?top , left .... 絳夊彲浠ョ敤 .jsp鏉ュ仛 鍐嶇敤dojoLayout鍔犲叆涓婚〉闈?.html
聽聽聽聽聽聽聽聽聽 --------鍦嗘槸-----------
鍏朵粬涓嶇敤鍐嶈浜嗗惂!!
聽
聽