当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Jquery 学习笔记(一)

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 Jquery 学习笔记(一)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-10   浏览: 311 ::
收藏到网摘: n/a

从今天起正式学习Jquery(实际严格讲已经用了几个月的Jquery的一丁点东西),边学边做边记笔记;阅读书籍《锋利的Jquery》+Jquery API Doc。 基础知识:
想要结构与行为分离当然不能使用<button onclick="…"></button>之类的东西了,js是写在<head>之间的,那就说起了 window.onload——这不是一个好东西,所以就有了Jquery颇具创意的
复制代码 代码如下:

$(document).ready(funciton(){

});

当然还会更精简:
复制代码 代码如下:

$(function(){

});

所以我的第一个Jquery脚本就是这样的。
$(function(){alert("I'm ready")});
Jquery对象的方法与DOM对象的方法是不能混合使用的。例如$("#id").innerHTML或者document.getElementById("id").html()都是错误的。
Jquery对象与DOM对象的转换,Jquery选择器返回的对象实则是以对象数组的方式返回的,因此可以使用数组下标进行转换。也可使用Jquery中的get(index)方法
复制代码 代码如下:

$(function(){
var $p=$("p");
var p=$p[0];//var p=$p.get(0);
alert(p.innerHTML);
});

也可将DOM对象转换为Jquery对象
复制代码 代码如下:

var p=document.getElementById("p");
var $p=$(p);