Home  >  Article  >  Web Front-end  >  When the browser opens the layer, it automatically expands and shrinks slowly. Example code_jquery

When the browser opens the layer, it automatically expands and shrinks slowly. Example code_jquery

WBOY
WBOYOriginal
2016-05-16 17:30:091179browse
例子:
复制代码 代码如下:





无标题文档











解释上面代码段:
1、$("#warn").slideUp("slow");向上滑动, $("#warn").slideDown(2000);向下滑动
2、$.post(window.location.href,{op : 'setwarn'},function(data)
{
return true;
})
运用到了ajax 提交 跟服务器进行交互,
第一个参数是请求的地址 第二个是提交的参数 第三个是请求成功 之后调用的方法
参数op 的值是setwarn json串的格式具体运用解说看http://www.w3school.com.cn/jquery/ajax_post.asp
url 对应 locaotion.href(取得是当前页面的地址)
data对应 {op:setwarn} 字符串
success 对应 函数

3、window.onload = function(){}作用一般在中写的函数都要在body页面中调用,用此函数就不用等着body页面中调用就可以执行了
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn