| jquery简单体验 |
|
|
|
| Written by LXR | |
| Monday, 17 September 2007 20:36 | |
|
jquery是继prototype之后又一个优秀的Javascript框架。对prototype我使用不多,简单了解过。但使用上jquery之后,马上被她的优雅吸引住了。有人使用这样的一比喻来比较prototype和jquery:prototype就像Java,而jquery就像ruby.实际上我比较喜欢java(少接触Ruby罢了)但是jquery的简单的实用的确有相当大的吸引力啊!在项目里我把jquery作为自已唯一的框架类包。使用其间也有一点点心得,其实这些心得,在jquery的文档上面也可能有讲,不过还是记下来,以备忘罢。 代码
var someElement = $("#myId");
代码
$("div p");(1) $("div.container")(2) $("div #msg");(3) $("table a",context);(4)
代码
var a = $("#cid");(1) var b = $("<p>hello</p>");(2) var c = document.createElement("table"); var tb = $(c);
代码
$(document).ready(function(){ alert("hello"); });(1)
<body onload="alert('hello');">(2)
代码
$(document).ready(function(){ $("#clear").click(function(){ alert("i am about to clear the table"); }); $("form[0]").submit(validate); }); function validate(){ //do some form validation }
代码
$("#msg").html(); $("#msg").html("hello");
代码
$.get("search.do",{id:1},rend); function rend(xml){ alert(xml); } (1) $.post("search.do",{id:1},rend); function rend(xml){ alert(xml); } (2)
$("#msg").ajaxStart(function(){ this.html("正在加载。。。。"); });(3) $("#msg").ajaxSuccess(function(){ this.html("加载完成!"); });(4)
代码
$("#msg").fadeIn("fast"); $("#msg").fadeOut("slow");
写得很烂。可能大家看不出jquery的好处。嗯,光听是没用的,试用一下吧。你会发觉很有趣。 加一些Jquery的资源:
Set as favorite
Bookmark
Email This
Hits: 2439 Comments (0)
![]() Write comment
Newer news items:
|




