基于jquery的DIV隨滾動(dòng)條滾動(dòng)而滾動(dòng)的代碼
更新時(shí)間:2012年07月20日 18:56:57 作者:
基于jquery的DIV隨滾動(dòng)條滾動(dòng)而滾動(dòng)的代碼,有了JQuery簡單多了,就幾行代碼搞定
核心代碼:
<script type="text/javascript" src="http://demo.jb51.net/jslib/jquery/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function() {
$(window).scroll(function() {
var top = $(window).scrollTop()+200;
var left= $(window).scrollLeft()+320;
$("#editInfo").css({ left:left + "px", top: top + "px" });
});
});
</script>
<div id="editInfo" style="float:left;width:300px;background-color:#ccc;position:absolute;top:200px;">
<div>用戶名:<input type="text" /></div>
<div>密碼:<input type="text" /></div>
<div>年齡:<input type="text" /></div>
<div>備注:<input type="text" /></div>
<div><input type="button" value="保存" /></div>
</div>
<div style="height:1500px"></div>
在線演示 http://demo.jb51.net/js/2012/jquery_demo/jquery_div.html
記得以前寫這樣的代碼比較麻煩,現(xiàn)在有了JQuery簡單多了,就幾行代碼搞定!
復(fù)制代碼 代碼如下:
<script type="text/javascript" src="http://demo.jb51.net/jslib/jquery/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function() {
$(window).scroll(function() {
var top = $(window).scrollTop()+200;
var left= $(window).scrollLeft()+320;
$("#editInfo").css({ left:left + "px", top: top + "px" });
});
});
</script>
<div id="editInfo" style="float:left;width:300px;background-color:#ccc;position:absolute;top:200px;">
<div>用戶名:<input type="text" /></div>
<div>密碼:<input type="text" /></div>
<div>年齡:<input type="text" /></div>
<div>備注:<input type="text" /></div>
<div><input type="button" value="保存" /></div>
</div>
<div style="height:1500px"></div>
在線演示 http://demo.jb51.net/js/2012/jquery_demo/jquery_div.html
記得以前寫這樣的代碼比較麻煩,現(xiàn)在有了JQuery簡單多了,就幾行代碼搞定!
您可能感興趣的文章:
- js/jquery獲取瀏覽器窗口可視區(qū)域高度和寬度以及滾動(dòng)條高度實(shí)現(xiàn)代碼
- JQuery獲取元素文檔大小、偏移和位置和滾動(dòng)條位置的方法集合
- jQuery scroll事件實(shí)現(xiàn)監(jiān)控滾動(dòng)條分頁示例
- jquery easyui滾動(dòng)條部分設(shè)置介紹
- jquery 判斷滾動(dòng)條到達(dá)了底部和頂端的方法
- 基于jquery的橫向滾動(dòng)條(滑動(dòng)條)
- jQuery 錨點(diǎn)跳轉(zhuǎn)滾動(dòng)條平滑滾動(dòng)一句話代碼
- asp.net+jquery滾動(dòng)滾動(dòng)條加載數(shù)據(jù)的下拉控件
- JS和JQUERY獲取頁面大小,滾動(dòng)條位置,元素位置(示例代碼)
- jquery滾動(dòng)條插件slimScroll使用方法
相關(guān)文章
jQuery對象數(shù)據(jù)緩存Cache原理及jQuery.data方法區(qū)別介紹
jQuery.data(..)來實(shí)現(xiàn)數(shù)據(jù)緩存,但有兩個(gè)用戶經(jīng)常使用的data([key],[value])和jQuery.data(element,[key],[value]),接下來為大家介紹下他們的區(qū)別,感興趣的朋友可以參考下哈2013-04-04
關(guān)于jquery form表單序列化的注意事項(xiàng)詳解
這篇文章主要給大家介紹了關(guān)于jquery form表單序列化的注意事項(xiàng),文中通過示例代碼介紹的非常詳細(xì),對大家具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面跟著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2017-08-08

