本文实例讲述了JQuery获取元素尺寸、位置及页面滚动事件应用。分享给大家供大家参考,具体如下:
获取元素尺寸
Title .box{ width: 300px; height: 200px; padding: 20px; border: 10px solid #000; margin: 20px; background-color: gold; } dd
获取元素绝对位置
Title .box{ width: 200px; height: 200px; background-color: #f6b544; margin: 50px auto 0; }
主要就是offset()函数
加入购物车动画
设置一个按钮,一个购物车框,一个小方框(隐藏)。点击按钮之后,小方框的位置从按钮以animate动画的形式放到购物车框,购物车的数量加一:
Title .chart{ width: 150px; height: 50px; border: 2px solid #000; text-align: center; line-height: 50px; float: right; margin-right:100px ; margin-top: 100px; } .chart em{ font-style: normal; color: red; font-weight: bold; } .add{ width: 100px; height: 50px; border: 0; background-color: green; color: #fff; float: left; margin-top: 300px; margin-left: 300px; } .points{ width: 16px; height: 16px; background-color: red; position: fixed; left: 0; top: 0; display: none; z-index: 999; } 购物车0
感兴趣的朋友可以使用在线HTML/CSS/Javascript代码运行工具 http://tools.jb51.net/code/HtmlJsRun 测试上述代码运行效果。
更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery常见事件用法与技巧总结》、《jQuery常用插件及用法总结》、《jQuery操作json数据技巧汇总》、《jQuery扩展技巧总结》、《jQuery常见经典特效汇总》及《jquery选择器用法总结》
希望本文所述对大家jQuery程序设计有所帮助。



