首页 > 代码库 > jQuery滑动并响应事件
jQuery滑动并响应事件
jQuery滑动并打开指定页面:
<!DOCTYPE html><html><head><script src="http://code.jquery.com/jquery-1.11.1.min.js"></script><script> $(document).ready(function(){ $(".a").click(function(){ $(".a").animate({left:‘250px‘},function(){location.href="http://www.baidu.com"}); });});</script> </head> <body><p>默认情况下,所有 HTML 元素的位置都是静态的,并且无法移动。如需对位置进行操作,记得首先把元素的 CSS position 属性设置为 relative、fixed 或 absolute。</p><h3>点击方块执行</h3><div class=‘a‘ style="background:#98bf21;height:100px;width:100px;position:absolute;"></div></body></html>
jQuery来回滑动并响应事件:
<!DOCTYPE html><html><head><script src="jquery/jquery.js"></script><script> $(document).ready(function(){ $("#box").toggle(function(){ $("#box").animate({left:‘200px‘},function(){alert(‘Slide to the right‘);}).text(‘ON‘);}, function(){ $("#box").animate({left:‘‘},function(){alert(‘Sliding to the left‘);}).text(‘OFF‘);} );});</script> </head><body><p>默认情况下,所有 HTML 元素的位置都是静态的,并且无法移动。如需对位置进行操作,记得首先把元素的 CSS position 属性设置为 relative、fixed 或 absolute。</p><h3>点击方块执行</h3><div id=‘box‘ style="background:#98bf21;height:100px;width:100px;position:absolute;">OFF</div></body></html>
jQuery下载:http://files.cnblogs.com/liuswi/jquery.js
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。