| jQuery使用手册--核心篇(Core) |
|
|
|
| Written by LXR | |||
| Monday, 17 September 2007 22:26 | |||
|
jQuery使用手册--核心篇(Core) <script language="javascript" type="text/javascript"> $(document).ready(function(){ $("a").click(function(){ alert("Hello world!"); }); }); <script>
<p>one</p> <div> <p>two</p> </div> <p>three</p> <a href="#" id="test" onClick="jq()" >jQuery</a> CODE: jQuery代码及功能: function jq(){ alert($("div > p").html()); }
function jq(){ $("<div><p>Hello</p></div>").appendTo("body"); }
<p>one</p> <div> <p>two</p> </div><p>three</p> <a href="#" id="test" onClick="jq()">jQuery</a>
function jq(){ alert($(document).find("div > p").html()); }
function jq(){ $(document.body).css("background","black"); }
<form id="form1"> <input type="text" name="textfield"> <input type="submit" name="Submit" value="提交"> </form> <a href="#" id="test" onClick="jq()">jQuery</a>
CODE: function jq(){ $(form1.elements ).hide(); }
$(function(){ $(document.body).css("background","black"); })
<p>one</p> <div> <p>two</p> </div> <p>three</p> <a href="#" id="test" onClick="jq()">jQuery</a>
function jq(){ var f = $("div"); alert($(f).find("p").html()) }
<img src="1.jpg"/> <img src="1.jpg"/> <a href="#" id="test" onClick="jq()">jQuery</a> CODE: jQuery代码及功能: function jq(){ $("img").each(function(){ this.src = "2.jpg"; }); }
<p>This is just a test.</p> <p>So is this</p> <a href="#" id="test" onClick="jq()">jQuery</a>
function jq(){ alert($("p").eq(1).html()) }
<p>This is just a test.</p> <p>So is this</p> <a href="#" id="test" onClick="jq()">jQuery</a>
function jq(){ alert($("p").get(1).innerHTML); }
<div id="test1"></div> <div id="test2"></div> <a href="#" id="test" onClick="jq()">jQuery</a>
CODE:
function jq(){ alert($("div").index(document.getElementById('test1'))); alert($("div").index(document.getElementById('test2'))); }
CODE:
<img src="test1.jpg"/> <img src="test2.jpg"/> <a href="#" id="test" onClick="jq()">jQuery</a>
CODE: function jq(){ alert($("img").length); }
Set as favorite
Bookmark
Email This
Hits: 2098 Comments (0)
![]() Write comment
Newer news items:
Older news items:
|




