当前位置: 首页 > 图文教程 > 网络编程 > 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-20   浏览: 183 ::
收藏到网摘: n/a

下面简单介绍一下jQuery的一些特性和用法,对于学习jquery的朋友有不少帮助。 1.精准简单的选择对象(dom):
复制代码 代码如下:

$('#element');// 相当于document.getElementById
("element")
$('.element');//Class
$('p');//html标签
$("form > input");//子对象
$("div,span,p.myClass");//同时选择多种对象
$("tr:odd").css("background-color", "#bbbbff");//表格的
隔行背景
$(":input");//表单对象
$("input[name='newsletter']");//特定的表单对象

2.对象函数的应用简单和不限制:
复制代码 代码如下:

element.function(par);
$(”p.surprise”).addClass(”ohmy”).show(”slow”)...

3.对已选择对象的操作(包括样式):
复制代码 代码如下:

$("#element").addClass("selected");//给对象添加样式
$('#element').css({ "background-color":"yellow", "font
-weight":"bolder" });//改变对象样式
$("p").text("Some new text.");//改变对象文本
$("img").attr({ src: "test.jpg", alt: "Test Image"
});//改变对象文本
$("p").add("span");//给对象增加标签
$("p").find("span");//查找对象内部的对应元素
$("p").parent();//对象的父级元素
$("p").append("<b>Hello</b>");//给对象添加内容

4.支持aJax,支持文件格式:xml/html/script/json/jsonp
复制代码 代码如下:

$("#feeds").load("feeds.html");//相应区域导入静态页内容
$("#feeds").load("feeds.php", {limit: 25}, function()
{alert("The last 25 entries in the feed have been
loaded");});//导入动态内容

5.对事件的支持:
复制代码 代码如下:

$("p").hover(function () {
$(this).addClass("hilite");//鼠标放上去时
}, function () {
$(this).removeClass("hilite");//移开鼠标
});//鼠标放上去和移开的不同效果(自动循环所有p对象


6.动画:
复制代码 代码如下:

$("p").show("slow");//隐藏对象(慢速渐变)
$("#go").click(function(){
$("#block").animate({
width: "90%",
height: "100%",
fontSize: "10em"
}, 1000 );
});//鼠标点击后宽、高、字体的动态变化

7.扩展:
复制代码 代码如下:

$.fn.background = function(bg){
return this.css('background', bg);
};
$(#element).background("red");