蛇精脸视频百度网盘:jquery 简单学习(5)
JQuery简单学习(5)——JQuery效果
文章分类:Web前端
jQuery 是为事件处理特别设计的。
————————————————————jQuery 事件函数隐藏、显示、切换、滑动 以及动画实例jQuery hide() Js代码If you click on me, I will disappear.
演示简单的 jQuery hide() 函数。If you click on me, I will disappear.
jQuery hide() Js代码
Island Trading
- class="ex">
Contact: Helen Bennett
- Garden House Crowther Way
- London
Paris Trading
- class="ex">
Contact: Marie Bertrand
- 265, Boulevard Charonne
- Paris
另一个 hide() 演示。如何隐藏部分文本。Island Trading
Contact: Helen Bennett
Garden House Crowther Way
LondonParis Trading
Contact: Marie Bertrand
265, Boulevard Charonne
Paris
jQuery slideToggle() Js代码
- class="panel">
Because time is valuable, we deliver quick and easy learning.
At W3School, you can study everything you need to learn, in an accessible and handy format.
class="flip">Show/Hide Panel
演示简单的 slide panel 效果。Because time is valuable, we deliver quick and easy learning.
At W3School, you can study everything you need to learn, in an accessible and handy format.
Show/Hide Panel
jQuery fadeTo() Js代码
- "test" s="background:yellow;width:300px;height:300px">
演示简单的 jQuery fadeTo() 函数。
jQuery animate() Js代码
- "box"
- s="background:#98bf21;height:100px;width:100px;position:relative">
演示简单的 jQuery animate() 函数。
————————————————————jQuery 隐藏和显示通过 hide() 和 show() 两个函数,jQuery 支持对 HTML 元素的隐藏和显示:
实例Js代码
"p1">If you click on the "Hide" button, I will disappear.
hide() 和 show() 都可以设置两个可选参数:speed 和 callback。If you click on the "Hide" button, I will disappear.
语法:Js代码
- $(selector).hide(speed,callback)
- $(selector).show(speed,callback)
$(selector).hide(speed,callback)$(selector).show(speed,callback)callback 参数是在 hide 或 show 函数完成之后被执行的函数名称。您将在本教程下面的章节学习更多有关 callback 参数的知识。
speed 参数可以设置这些值:"slow", "fast", "normal" 或 milliseconds:
实例Js代码
This is a paragraph with little content.
This is another small paragraph.
————————————————————jQuery 切换jQuery toggle() 函数使用 show() 或 hide() 函数来切换 HTML 元素的可见状态。This is a paragraph with little content.
This is another small paragraph.
隐藏显示的元素,显示隐藏的元素。
语法:Js代码
- $(selector).toggle(speed,callback)
$(selector).toggle(speed,callback)speed 参数可以设置这些值:"slow", "fast", "normal" 或 毫秒。
实例Js代码
This is a paragraph with little content.
This is another small paragraph.
callback 参数是在 hide 或 show 函数完成之后被执行的函数名称。您将在本教程下面的章节学习更多有关 callback 参数的知识。 ————————————————————jQuery 滑动函数 - slideDown, slideUp, slideTogglejQuery 拥有以下滑动函数:Js代码This is a paragraph with little content.
This is another small paragraph.
- $(selector).slideDown(speed,callback)
- $(selector).slideUp(speed,callback)
- $(selector).slideToggle(speed,callback)
$(selector).slideDown(speed,callback)$(selector).slideUp(speed,callback)$(selector).slideToggle(speed,callback)speed 参数可以设置这些值:"slow", "fast", "normal" 或 毫秒。
callback 参数是在 hide 或 show 函数完成之后被执行的函数名称。您将在本教程下面的章节学习更多有关 callback 参数的知识。
slideDown() 实例
Js代码
- class="panel">
Because time is valuable, we deliver quick and easy learning.
At W3School, you can study everything you need to learn, in an accessible and handy format.
class="flip">Show Panel
Because time is valuable, we deliver quick and easy learning.
At W3School, you can study everything you need to learn, in an accessible and handy format.
Show Panel
slideUp() 实例
Js代码- class="panel">
Because time is valuable, we deliver quick and easy learning.
At W3School, you can study everything you need to learn, in an accessible and handy format.
class="flip">Hide Panel
slideToggle() 实例 Js代码Because time is valuable, we deliver quick and easy learning.
At W3School, you can study everything you need to learn, in an accessible and handy format.
Hide Panel
- class="panel">
Because time is valuable, we deliver quick and easy learning.
At W3School, you can study everything you need to learn, in an accessible and handy format.
class="flip">Show/Hide Panel
————————————————————jQuery Fade 函数 - fadeIn(), fadeOut(), fadeTo()jQuery 拥有以下 fade 函数:Js代码Because time is valuable, we deliver quick and easy learning.
At W3School, you can study everything you need to learn, in an accessible and handy format.
Show/Hide Panel
- $(selector).fadeIn(speed,callback)
- $(selector).fadeOut(speed,callback)
- $(selector).fadeTo(speed,opacity,callback)
$(selector).fadeIn(speed,callback)$(selector).fadeOut(speed,callback)$(selector).fadeTo(speed,opacity,callback)speed 参数可以设置这些值:"slow", "fast", "normal" 或 毫秒。
fadeTo() 函数中的 opacity 参数规定减弱到给定的不透明度。
callback 参数是在 hide 或 show 函数完成之后被执行的函数名称。您将在本教程下面的章节学习更多有关 callback 参数的知识。
fadeTo() 实例Js代码
- "test" s="background:yellow;width:300px;height:300px">
fadeOut() 实例Js代码
- "test" s="background:yellow;width:200px">CLICK ME AWAY!
If you click on the box above, it will be removed.
————————————————————jQuery 自定义动画jQuery 函数创建自定义动画的语法:Js代码CLICK ME AWAY!If you click on the box above, it will be removed.
- $(selector).animate({params},[duration],[easing],[callback])
$(selector).animate({params},[duration],[easing],[callback])关键的参数是 params。它定义了产生动画的属性。可以同时设置多个此类属性:Js代码
- animate({width:"70%",opacity:0.4,marginLeft:"0.6in",fontSize:"3em"});
animate({width:"70%",opacity:0.4,marginLeft:"0.6in",fontSize:"3em"});第二个参数是 duration。它定义用来应用于动画的时间。它设置的值是:"slow", "fast", "normal" 或 毫秒。
实例 1Js代码
- "box"
- s="background:#98bf21;height:100px;width:100px;position:relative">
实例 2Js代码
- "box"
- s="background:#98bf21;height:100px;width:200px;position:relative">
- HELLO
HTML 元素默认是静态定位,且无法移动。HELLO
如需使元素可以移动,请把 CSS 的 position 设置为 relative 或 absolute。
————————————————————
jQuery 效果 - 来自本页
函数描述 $(selector).hide() 隐藏被选元素 $(selector).show() 显示被选元素 $(selector).toggle() 切换(在隐藏与显示之间)被选元素 $(selector).slideDown() 向下滑动(显示)被选元素 $(selector).slideUp() 向上滑动(隐藏)被选元素 $(selector).slideToggle() 对被选元素切换向上滑动和向下滑动 $(selector).fadeIn() 淡入被选元素 $(selector).fadeOut() 淡出被选元素 $(selector).fadeTo() 把被选元素淡出为给定的不透明度 $(selector).animate() 对被选元素执行自定义动画