前端必备:jQuery 1.7.1API手册

news/2024/7/10 23:44:10 标签: jquery, input, callback, function, div, html
<html" title=div>div id="article_content" class="article_content clearfix"> <html" title=div>div id="content_views" class="htmledit_views">

<html" title=div>div id="cnblogs_post_body" style="word-break:normal!important; font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:13px; line-height:19px">

本文基于jQuery1.7.1版本,是对官方API的整理和总结,完整的官方API见http://api.html" title=jquery>jquery.com/browser/

0、总述

jQuery框架提供了很多方法,但大致上可以分为3大类:获取jQuery对象的方法、在jQuery对象间跳转的方法,以及获取jQuery对象后调用的方法


其中第一步是怎样获取jQuery对象。大致来说,是通过最核心的$()方法,将页面上的元素(或者在页面上不存在的html片段)包装成jQuery对象。

$()方法里面支持的语法又包括3大类,分别是表达式(包括类表达式.,id表达式#,元素表达式等)、符号(包括后代符号space,next符号+等)、过滤器(包括:过滤器和[]过滤器)。

通过以上3种的组合,“查询”得到想要操作的元素或者元素集合,作为$()的参数,得到jQuery对象(或者jQuery对象的集合)

第二步是在jQuery对象间的跳转。也就是说,已经得到了一个jQuery对象,但是并不是想要的,那么可以通过一系列的跳转方法,比如parent()、next()、children()、find()等,或者过滤筛选的方法,比如eq()、filter()、not()等,来得到最终想要操作的jQuery对象。

用跳转和过滤方式得到的jQuery结果,往往通过比较复杂的表达式组合,可以达到同样的目的。

比如说$("html" title=div>div").eq(3),也可以用$("html" title=div>div:eq(3)")达到同样的目的。

又比如说$("html" title=div>div").find("span"),可以用$("html" title=div>div span")取到同样的元素。

方法是很灵活的,要根据具体的情况来选择。一般来说,HTML页面写得越规范,使用jQuery就越简单

还有一种情况,在得到了jQuery()对象之后,想要判断其是否满足条件,那么可以调用is()、hasClass()等方法,返回一个boolean值,进行后续的判断。这类方法也可以归到这类。

第三步是在获取准确的jQuery对象之后,调用其上的各种方法,来进行操作。这一步反而是比较简单的了。

后面就是对jQuery框架各种方法的简要介绍,更详细的内容,还是以官方API为准

1、$(...)

$() 一切的核心,可以跟4种参数

$(expression),比如$("#id")、$(".class")等,返回jQuery对象,或者jQuery对象的集合

$(html),比如$("<span>hello world</span>"),返回jQuery对象,或者jQuery对象的集合

$(element),比如$(document.body),返回jQuery对象,或者jQuery对象的集合

$(*),所有元素

2、jQuery Object Accessors

jQuery.index(element),返回该jQuery对象在集合中的索引

jQuery.each(html" title=function>function),遍历jQuery对象集合,在每个对象上执行html" title=function>function函数,html" title=function>function html" title=callback>callback(index, domElement){this};

jQuery.size(),返回jQuery对象集合的大小

jQuery.length,相当于size()方法

jQuery.get(),获取原生DomElement对象的Array

jQuery.get(index),获取原生DomElement对象

jQuery.eq(position),获取jQuery对象集合中的一个jQuery对象

3、Data相关方法

jQuery.data(name)  返回元素上储存的相应名字的数据,可以用data(name,value)来设定

jQuery.data(name, value)

jQuery.removeData(name)

4、选择符

multiple(selector1, selector2),可以选择多个元素或者表达式,包装成jQuery对象的集合

例子:$("html" title=div>div,span")

id(id)

例子:$("#id")

class(class)

例子:$(".class")

element(element)

例子:$("html" title=div>div")

all

例子:$("*")

descendant

例子:$("table tr td")

child(parent, child)

例子:$("#id > span"),和上一个descendant的区别在于,descendant只要是后代就会被选中,而child必须是直接子节点,不包括孙子节点

next(prev, next)

例子:$("label + html" title=input>input"),选中的是label标签的下一个html" title=input>input标签,返回jQuery对象的集合

siblings(prev, siblings)

例子:$("#prev ~ html" title=div>div"),选中的是#prev之后的所有html" title=div>div标签,返回jQuery对象的集合,有点像next,但是范围更大

Basic Filters

$(":header"),选中所有header,包括<h1><h2>等

$("tr:odd"),选中所有奇数行

$("tr:even"),选中所有偶数行

$(":animated"),选中所有当前有特效的元素,$("html" title=div>div:animated"),选中当前所有有特效的<html" title=div>div>

$("tr:first"),选中第一行

$("tr:last"),选中最后一行

$("html" title=input>input:not(:checked)"),选中所有没有“checked”的html" title=input>input元素

$("td:gt(4)"),选中所有index是4之后的td

$("td:lt(4)"),选中所有index是4之前的td

$("td:eq(4)"),选中index是4的td,可以用$("td").eq(4)来实现同样的效果

Content Filters

$("html" title=div>div:contains('John')"),选中所有包含"John"字符串的html" title=div>div

$("td:empty"),选中所有内容为空的td

$("html" title=div>div:has(p)"),选中包含有<p>元素的<html" title=div>div>元素,返回jQuery对象集合

$("td:parent"),选中所有包含子节点的元素,包括文本也可以算是子节点

Visibility Filters

$("span:hidden"),选中所有隐藏的<span>

$("span:visible"),选中所有可见的<span>

Attribute Filters

$("html" title=div>div[id]"),选中包含id属性的<html" title=div>div>元素

$("html" title=input>input[name$='letter']"),选中包含某个属性的<html" title=input>input>元素,这个属性名是以'letter'结尾的

$("html" title=input>input[name^='letter']"),选中包含某个属性的<html" title=input>input>元素,这个属性名是以'letter'开头的

$("html" title=input>input[name*='man']"),选中包含某个属性的<html" title=input>input>元素,这个属性的属性名里包含'man'

$("html" title=input>input[name='newsletter']"),选中包含一个属性的<html" title=input>input>元素,这个属性的名字是'newsletter'

$("html" title=input>input[name!='newsletter']"),选中所有不包含'newsletter'属性的<html" title=input>input>元素

$("html" title=input>input[id][name$='man']"),选中包含id属性,和以'man'结尾属性的<html" title=input>input>元素

Child Filters

$("ul li:nth-child(2)"),选中自身是<ul>元素的第二个子节点的<li>元素,注意这个计算是从1开始的,不是从0开始

$("html" title=div>div span:firstChild"),选中自身是<html" title=div>div>元素的第一个子节点的<span>元素

$("html" title=div>div span:lastChild"),选中自身是<html" title=div>div>元素的最后一个子节点的<span>元素

$("html" title=div>div span:onlyChild"),选中自身是<html" title=div>div>元素的唯一子节点的<span>元素

Forms

$(":button"),所有<button>元素,和<html" title=input>input type="button">元素

$("form :checkbox"),选中所有<form>标签下的<html" title=input>input type="checkbox">,不过这样会比较慢,官方建议使用$("html" title=input>input:checkbox")

$(":file"),选中所有<html" title=input>input type="file">

$(":hidden"),选中所有隐藏元素,以及<html" title=input>input type="hidden">

$(":html" title=input>input"),选中所有<html" title=input>input>

$(":text"),选中所有<html" title=input>input type="text">

$(":password"),选中所有<html" title=input>input type="password">

$(":radio"),选中所有<html" title=input>input type="radio">,不过这样会比较慢,建议使用$("html" title=input>input:radio")

$(":image"),选中所有<html" title=input>input type="image">

$(":reset"),选中所有<html" title=input>input type="reset">

$(":submit"),选中所有<html" title=input>input type="submit">

Form Filters

$("html" title=input>input:enabled"),选中所有enabled的<html" title=input>input>元素

$("html" title=input>input:disabled"),选中所有disabled的<html" title=input>input>元素

$("html" title=input>input:checked"),选中所有checked的<html" title=input>input type="checkbox">元素

$("html" title=input>input:selected"),选中所有selected的<option>元素

5、属性相关的方法

jQuery.removeAttr(name)

jQuery.attr(name),返回属性的值,比如$("img").attr("src")

jQuery.attr(key,value),这是设置属性的值

jQuery.attr(properties),也是设置属性的值

例子:

  1. $("img").attr({   
  2. src: "/images/hat.gif",   
  3. title: "jQuery",   
  4. alt: "jQuery Logo"   
  5. });   

jQuery.attr(key,html" title=function>function),也是设置属性的值,这个html" title=function>function计算出的结果,赋给key

  1. html" title=function>function html" title=callback>callback(index) {   
  2. // index == position in the jQuery object   
  3. // this means DOM Element   
  4. }  

6、class相关的方法

jQuery.toggleClass(class),反复切换class属性,该方法第一次执行,增加class,然后去除该class,循环

jQuery.toggleClass(class,switch),增加一个switch表达式

jQuery.hasClass(class),返回boolean

jQuery.removeClass(class),删除class

jQueyr.addClass(class),增加class

7、HTML相关的方法

jQuery.html(),返回包含的html文本

jQuery.html(val),用val替换包含的html文本

8、文本相关的方法

jQuery.text(),返回包含的纯文本,不会包括html标签,比如<span>abcd</span>,调用.text()方法,只会返回abcd,不会返回<span>abcd</span> 
jQuery.text(val),用val替换包含的纯文本,和html(val)方法的区别在于,所有的内容会被看作是纯文本,不会作为html标签进行处理,比如调用.text("<span>abcd</span>"),<span>和</span>不会被认为是html标签

9、值相关的方法

jQuery.val(),返回string或者array

jQuery.val(val),设置string值

jQuery.val(array),设置多个值,以上3个方法,主要都是用在表单标签里,如<html" title=input>input type="text">,<html" title=input>input type="checkbox">等

10、在jQuery对象集合中进行过滤

以下几类方法有点像把选择符Filter进行方法化,比如$("label:eq(4)"),取到第4个<label>元素,这个就可以用$("label").eq(4)来替代,达到同样的效果

jQuery.is(expr),返回boolean,比如$(this).is(":first-child"),判断一个元素,是不是其父节点的第一个子节点

jQuery.eq(index),$("html" title=div>div").eq(2),取出第2个<html" title=div>div>元素

jQuery.filter(expr),比如$("html" title=div>div").filter(".middle"),会从html" title=div>div元素中筛选出属于middle的class的元素;再比如$("p").filter(".selected, :first"),会取出是selected类,或者是第一个元素的<p>元素,这个可以用$("p.class, p:first")来代替这个方法,会从初始的结果集中,筛选保留一部分

jQuery.filter(fn),类似于上一个函数,可以传进去一个html" title=function>function,用这个html" title=function>function的返回值,进行筛选

  1. html" title=function>function html" title=callback>callback(index){   
  2. // index == position in the jQuery object   
  3. // this means DOM Element   
  4. return boolean;   
  5. }  

jQuery.not(expr),是和filter(expr)相反的方法,不是和is(expr)相反的方法。该方法把满足expr的元素给排除掉,比如$("html" title=div>div").not(".green, #blue"),把class是green或者id是blue的元素过滤掉

jQuery.slice(start, end),从jQuery对象集合中选出一段

jQuery.map(html" title=callback>callback),不知道是干嘛的

11、在jQuery对象之间查找

jQuery.parent(expr),找父亲节点,可以传入expr进行过滤,比如$("span").parent()或者$("span").parent(".class")

jQuery.parents(expr),类似于jQuery.parent(expr),但是是查找所有祖先元素,不限于父元素

jQuery.children(expr),返回所有子节点,和parents()方法不一样的是,这个方法只会返回直接的孩子节点,不会返回所有的子孙节点

jQuery.contents(),返回下面的所有内容,包括节点和文本。这个方法和children()的区别就在于,包括空白文本,也会被作为一个jQuery对象返回,children()则只会返回节点

jQuery.prev(),返回上一个兄弟节点,不是所有的兄弟节点

jQuery.prevAll(),返回所有之前的兄弟节点

jQuery.next(),返回下一个兄弟节点,不是所有的兄弟节点

jQuery.nextAll(),返回所有之后的兄弟节点

jQuery.siblings(),返回兄弟姐妹节点,不分前后

jQuery.add(expr),往既有的jQuery对象集合中增加新的jQuery对象,例子:$("html" title=div>div").add("p")

jQuery.find(expr),跟jQuery.filter(expr)完全不一样。jQuery.filter()是从初始的jQuery对象集合中筛选出一部分,而jQuery.find()的返回结果,不会有初始集合中的内容,比如$("p").find("span"),是从<p>元素开始找<span>,等同于$("p span")

12、串联方法

jQuery.andSelf(),把最后一次查询前一次的集合,也增加到最终结果集中,比如$("html" title=div>div").find("p").andSelf(),这样结果集中包括所有的<p>和<html" title=div>div>。如果是$("html" title=div>div").find("p"),那就只有<p>,没有<html" title=div>div>

jQuery.end(),把最后一次查询前一次的集合,作为最终结果集,比如$("p").find("span").end(),这样的结果集,是所有的<p>,没有<span>

13、DOM文档操作方法

jQuery.append(content),这个方法用于追加内容,比如$("html" title=div>div").append("<span>hello</span>");

jQuery.appendTo(selector),这个方法和上一个方法相反,比如$("<span>hello</span>").appendTo("#html" title=div>div"),这个方法其实还有一个隐藏的move作用,即原来的元素被移动了

jQuery.prepend(content),跟append()方法相对应,在前面插入

jQuery.prependTo(selector),跟上一个方法相反

jQuery.after(content),在外部插入,插入到后面,比如$("#foo").after("<span>hello</span>");

jQuery.insertAfter(selector),和上一个方法相反,比如$("<span>hello</span>").insertAfter("#foo");

jQuery.before(content),在外部插入,插入到前面

jQuery.insertBefore(selector),跟上一个方法相反

jQuery.wrapInner(html),在内部插入标签,比如$("p").wrapInner("<span></span>");

jQuery.wrap(html),在外部插入标签,比如$("p").wrap("<html" title=div>div></html" title=div>div>"),这样的话,所有的<p>都会被各自的<html" title=div>div>包裹

jQuery.wrapAll(html),类似上一个,区别在于,所有的<p>会被同一个<html" title=div>div>包裹

jQuery.replaceWith(content),比如$(this).replaceWith("<html" title=div>div>"+$(this).text()+"</html" title=div>div>");

jQuery.replaceAll(selector),比如$("<html" title=div>div>hello</html" title=div>div>").replaceAll("p");

jQuery.empty(),比如$("p").empty(),这样的话,会把<p>下面的所有子节点清空

jQuery.remove(expr),比如$("p").remove(),这样的话,会把所有<p>移除,可以用表达式做参数,进行过滤

jQuery.clone(),复制一个页面元素

14、CSS相关方法

jQuery.css(name),获取一个css属性的值,比如$("p").css("color")

jQuery.css(object),设置css属性的值,比如$("p").css({"color":"red","border":"1px red solid"});

jQuery.css(name,value),设置css属性的值,比如$("p").css("color","red");

15、位置计算相关方法

jQuery.scrollLeft(),设置滚动条偏移,这个方法对可见元素或不可见元素都生效

jQuery.scrollTop(),设置滚动条偏移,这个方法对可见元素或不可见元素都生效

jQuery.offset(),计算偏移量,返回值有2个属性,分别是top和left

jQuery.position(),计算位置,返回值也有2个属性,top和left

16、宽度和高度计算相关方法

这组方法需要结合CSS的盒子模型来理解,margin始终不参与计算

jQuery.height(),这个方法计算的是content

jQuery.innerHeight(),这个方法计算的是content+padding

jQuery.outerHeight(),这个方法计算的是content+padding+border

jQuery.width();

jQuery.innerWidth();

jQuery.outerWidth();

17、页面加载完成事件

$(document).ready(html" title=function>function(){}),可以简写为$(html" title=function>function(){})

18、事件绑定方法

jQuery.bind(type,data,fn)

bind()方法可以接受3个参数,第1个是事件类型,类型是string,可能的值有blur, focus, load, resize, scroll, unload, beforeunload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select,

submit, keydown, keypress, keyup, error

第3个参数是当事件发生时,要执行的函数,函数原型是

  1. html" title=function>function html" title=callback>callback(eventObject) {   
  2. this// dom element   
  3. }  


在这个方法里return false会阻止事件冒泡并中止默认行为,如果在这个方法里调用eventObject.preventDefault()则会中止默认行为,如果在这个方法里调用eventObject.stopPropagation()则只会阻止事件冒泡

第2个参数是可选的,会赋值给e.data,比如

  1. html" title=function>function handler(event) {   
  2. alert(event.data.foo);   
  3. }   
  4. $("p").bind("click", {foo: "bar"}, handler)   

jQuery.one(type,data,fn),这个方法类似于bind()方法,区别在于只会绑定一次

jQuery.unbind(type,fn),解除绑定

jQuery.trigger(event,data),触发事件,要注意这个方法,同样会引起浏览器的默认行为,比如submit

另外,这个方法如果和bind()方法里定义的handler配合使用,可以更加灵活地传递参数,比如

  1. $("#test").bind("click", {name : "kyfxbl"}, html" title=function>function(e, foo) {   
  2. alert(e.data.name);   
  3. alert("foo: " + foo);   
  4. });  

以上代码,如果直接点击#test,则foo的值是undefined

但是如果通过$("#test").trigger("click",["foo"])来触发,则参数foo会被赋值为"foo"

jQuery.triggerHandler(event,data),这个方法和trigger()方法十分相像,主要有2点不同,1是这个方法不会触发浏览器的默认行为,2是它只会在jQuery对象集合的第一个元素上触发

jQuery.live(type,fn),这个方法十分类似jQuery.bind()方法,区别在于这个方法对后来才添加进来的元素同样有效

jQuery.die(type,fn),这个是jQuery.live()的相反方法

19、事件快捷方法

jQuery.hover(over,out),这个方法是mouseenter和mouseleave的便捷方法,2个参数的函数原型是:

  1. html" title=function>function html" title=callback>callback(eventObject) {   
  2. this// dom element   
  3. }   

jQuery.toggle(fn,fn2,fn3,...),这个方法是多次点击的便捷方法,参数的函数原型是:

  1. html" title=function>function html" title=callback>callback(eventObject) {   
  2. this// dom element   
  3. }  

jQuery提供了两类便捷方法:

第一类是类似于click()这种,相当于简化的jQuery.trigger()方法,比如$("p").click()相当于$("p").trigger("click"),不过该方法,无法像完整的jQuery.trigger("click", data)方法一样,传递一个附带的参数

第二类是类似于click(html" title=function>function)这种,相当于简化的jQuery.bind()方法,比如$("p").click(html" title=function>function)相当于$("p").bind("click",html" title=function>function),不过该方法,无法像完整的jQuery.bind("click", data, func)一样,传递一个额外的参数

20、切换元素显示与否的方法

jQuery.toggle(),原本显示的元素会不显示,原本不显示的会显示出来。这些元素可以是通过show()和hide()切换的,也可以是通过display:none来设置的

jQuery.show(),显示元素

jQuery.hide(),隐藏元素

jQuery.show(speed, html" title=callback>callback),类似于上面的jQuery.show(),不过可以设置速度以及回调函数

speed可以是"slow"、"normal"、"fast",也可以是毫秒数

html" title=callback>callback函数的原型是: 
html" title=function>function html" title=callback>callback() { 
this; // dom element 

jQuery.hide(speed, html" title=callback>callback) 
jQuery.toggle(speed, html" title=callback>callback)

21、页面一些特效方法

jQuery.slideDown(speed, html" title=callback>callback),让一个元素下滑,从无到有

jQuery.slideUp(speed, html" title=callback>callback),让一个元素上升,从有到无

jQuery.slideToggle(speed, html" title=callback>callback),切换一个下滑和上升

jQuery.fadeIn(speed, html" title=callback>callback),淡入效果

jQuery.fadeOut(speed, html" title=callback>callback),淡出效果

jQuery.fadeTo(speed, opacity, html" title=callback>callback),变淡效果

22、ajax相关方法

$.ajax(options),这个是底层方法,上层的$.get()和$.post()都是基于此方法的封装

options:

async:是否异步,默认为true

url:目标地址

type:请求类型,可以是"POST"或者"GET"

data:请求参数,比如"name=kyfxbl&location=shenzhen"

complete(html" title=function>function):请求结束后的回调函数,函数原型是

  1. html" title=function>function (XMLHttpRequest, textStatus) {   
  2. this// the options for this ajax request   
  3. }  

success(html" title=function>function):请求成功后的回调函数,函数原型是

  1. html" title=function>function (data, textStatus) {   
  2. // data could be xmlDoc, jsonObj, html, text, etc...   
  3. this// the options for this ajax request   
  4. }  


例子:

  1. $.ajax({   
  2. url : "user/ajax",   
  3. type : "GET",   
  4. data : "name=kyfxbl&location=shenzhen",   
  5. success : html" title=function>function(data, textStatus) {   
  6. alert(data);   
  7. alert(this.success);   
  8. }   
  9. });  


$.get(url, data, html" title=callback>callback, type),$.ajax()的简易方法,用于发送GET请求

url:请求地址

data:发送到服务端的请求参数

html" title=callback>callback:请求成功后的回调函数,函数原型是:

  1. html" title=function>function (data, textStatus) {   
  2. // data could be xmlDoc, jsonObj, html, text, etc...   
  3. this// the options for this ajax request   
  4. }  

$.post(url, data, html" title=callback>callback, type),$.ajax()的简易方法,跟$.get()差不多,用于发送POST请求

23、浏览器及特性检测

$.support,可以检测当前浏览器是否支持下列属性,返回boolean。包括boxModel、cssFloat、opacity、tbody等 
$.browser,检测当前浏览器类型,返回一个map,其中可能的值有safari、opera、msie、mozilla

24、数据缓存方法

该类方法是jQuery.data()方法和jQuery.removeData()的另一种形式,增加的elem参数是DOM Element

$.data(elem, name),取出elem上name的值

$.data(elem, name, value),设置elem上name的值为value

$.removeData(elem, name),删除elem上的name

$.removeData(elem),删除elem上的所有缓存数据

25、工具方法

$.isArray(obj),检测一个对象是否是数组

$.isFunction(obj),检测一个对象是否是函数

$.trim(str),去除string的空格

$.inArray(value, array),返回value在array中的下标,如果没有找到则返回-1,比如$.inArray(123, ["john",1,123,"f"])将会返回2

$.unique(array),去除array中的重复元素,该方法只对DOM Element有效,对string和number无效

html" title=div>div> <html" title=div>div id="MySignature" style="margin-top:10px; color:rgb(75,75,75); font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:13px; line-height:19px"> html" title=div>div> <html" title=div>div id="blog_post_info_block" style="margin-top:20px; color:rgb(75,75,75); font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:13px; line-height:19px"> <html" title=div>div id="blog_post_info">
html" title=div>div> html" title=div>div>


html" title=div>div> html" title=div>div> <html" title=div>div id="treeSkill">html" title=div>div>

http://www.niftyadmin.cn/n/1732367.html

相关文章

bootstrap中的按钮的使用(样式表)

可作为按钮使用的标签或元素为 <a>、<button> 或 <input> 元素添加按钮类&#xff08;button class&#xff09;即可使用 Bootstrap 提供的样式。Link 复制<a class"btn btn-default" href"#" role"button">Link</…

Bootstrap中的水平排列的表单

水平排列的表单通过为表单添加 .form-horizontal 类&#xff0c;并联合使用 Bootstrap 预置的栅格类&#xff0c;可以将 label 标签和控件组水平并排布局。这样做将改变 .form-group 的行为&#xff0c;使其表现为栅格系统中的行&#xff08;row&#xff09;&#xff0c;因此就…

setTimeOut(),setInterval的使用和区别

setTimeout("函数()",时间间隔)&#xff1b; setInterval&#xff08;“函数()”,时间间隔&#xff09;&#xff1b; 这两个方法语法相同&#xff0c;都有两个参数&#xff0c;一个是将要执行的代码字符串&#xff0c;还有一个是以毫秒为单位的时间间隔&#xff0c…

Bootstrap的表格排版实现方式

栅格系统Bootstrap 提供了一套响应式、移动设备优先的流式栅格系统&#xff0c;随着屏幕或视口&#xff08;viewport&#xff09;尺寸的增加&#xff0c;系统会自动分为最多12列。它包含了易于使用的预定义类&#xff0c;还有强大的mixin 用于生成更具语义的布局。简介栅格系统…

setTimeout和setInterval的区别你真的了解吗?

setTimeout和setInterval这两个函数, 大家肯定都不陌生, 但可能并不是每个用过这两个方法的同学, 都了解其内部的实质&#xff0c;甚至可能会错误的把两个实现定时调用的函数理解成了类似thread一样的东西, 认为会在一个时间片内, 并发的执行调用的函数, 似乎很好很强大, 但其实…

流行的更换图片的javascript函数集--MM_swapImage函数和MM_swapImgRestore函数

有些网页上的按钮,往往有两张不同的图片进行轮换,鼠标不动时,显示图片,鼠标移动到图片时候,显示另外一张图片.所以,就要使用下面几个javascript函数. <SCRIPT languageJavaScript typetext/JavaScript> <!-- //预先导入图片函数,往往是mouseover时候显示的图片 fun…

通过ajax给下拉框赋值中文乱码的问题

我最近在使用ajax技术从后台取值&#xff0c;并把结果绑定到前台的下拉框时&#xff0c;中文字符会出现乱码的现象&#xff0c;这个问题要怎么解决&#xff1f; 代码如下&#xff1a; function GetTel(userID, $, layer, siteURL, form) {$.ajax({type: "post",dat…

AlertBox 弹出层(信息提示框)效果

查看文档&#xff1a;文档引用&#xff1a;http://www.cnblogs.com/cloudgamer/archive/2010/10/11/AlertBox.html