jQuery 位置函数offset,innerWidth,innerHeight,outerWidth,oute

2016-02-19 13:16 19 1 收藏

在这个颜值当道,屌丝闪边的时代,拼不过颜值拼内涵,只有知识丰富才能提升一个人的内在气质和修养,所谓人丑就要多学习,今天图老师给大家分享jQuery 位置函数offset,innerWidth,innerHeight,outerWidth,oute,希望可以对大家能有小小的帮助。

【 tulaoshi.com - Web开发 】

代码如下:

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
html xmlns="http://www.w3.org/1999/xhtml"
head
titlejQuery的位置函数(offset(),innerWidth(),innerHeight(),outerWidth(),outerHeight(),scrollTop(),scrollLeft())小应用/title
style type="text/css"
#divShow{width:100px;height:50px;background-color:Green;display:none;}
#divAd{width:100px;height:100px;background-color:Red;position:absolute;top:100px;left:100px;}
/style
script type="text/javascript" src="js/jquery-1.3.2.min.js"/script
script type="text/javascript"
//在文本框下方显示一个div,类似日历控件那样。
function showDiv(obj){
jQuery("#divShow").css("left",jQuery(obj).offset().left);
jQuery("#divShow").css("top",jQuery(obj).offset().top + jQuery(obj).outerHeight());

jQuery("#divShow").show();
}
jQuery(function(){

});
//滚动条滚动,执行下面的函数,适合做浮动广告
jQuery(this).scroll(function(){
jQuery("#divAd").css("top",100 + jQuery(document).scrollTop());
jQuery("#divAd").css("left",100 + jQuery(document).scrollLeft());
});
/script
/head
body
input type="text" value="ok" onclick="showDiv(this);" /
div2010-03-22/div
div浮动广告/div
div用来撑出滚动条/div
/body
/html

来源:https://www.tulaoshi.com/n/20160219/1603620.html

延伸阅读
标签: Web开发
建议学习jquery的朋友学习下,了解下思路。 主要方法:$.browser.['浏览器关键字'] 代码: 代码如下: script type="text/javascript" $(function() { if($.browser.msie) { $( function() { alert("this is msie"); }); } else if($.browser.safari) { $( function() { alert("this is safari!"); }); } else if($.browser.mozill...
标签: Web开发
 //   排序:向上移动      function   Up()      ...{        var   sel=document.getElementById("selectCheck");  //获取select      var  &nb...
标签: Web开发
代码如下: !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" html head meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" titleEach Document/title script type="text/javascript" (function(){ //创建一个自执行函数 function _$(el){ //声明一个类 this.eleme...
标签: Web开发
便利的设置函数 jquery1.4的大部分设置值对方法都可以设置第二个参数为回调函数。比如:.css(), .attr(), .val(), .html(), .text()。 !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"html xmlns="http://www.w3.org/1999/xhtml"...
标签: Web开发
jQuery中10个非常有用的遍历函数 使用jQuery,可以很容易的选择HTML元素。但有些时候,在HTML结构较为复杂时,提炼我们选择的元素就是一件麻烦的事情。在这篇教程中,我们将探讨十种方法去精炼和扩展我们将要操作的集合。 HTML 首先,让我们看看下图所示的简单的页面,通过这个教程我们将选择这些元素。 div.contai...

经验教程

209

收藏

53
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部