`

jQuery获取margin-top和padding-top的值

阅读更多
var bordT = $('img').outerWidth() - $('img').innerWidth();
var paddT = $('img').innerWidth() - $('img').width();
var margT = $('img').outerWidth(true) - $('img').outerWidth();

var formattedBord = bordT + 'px';
var formattedPadd = paddT + 'px';
var formattedMarg = margT + 'px';


alert($this.parents("div:.item-form").css("marginTop").replace('px', ''));
alert($this.parents("div:.item-form").css("marginRight").replace('px', ''));
alert($this.parents("div:.item-form").css("marginBottom").replace('px', ''));
alert($this.parents("div:.item-form").css("marginLeft").replace('px', ''));

 

更多实例应用扫码体验:

 

分享到:
评论

相关推荐

    jQuery Selectors(选择器)的使用(一、基本篇)

    我的学习方法:先入门,后进阶!本系列文章分为:基本篇、层次篇、简单篇、内容篇、可见性篇、属性篇、子元素篇、表单... margin-top:15px; margin-right:15px; padding-left:5px; padding-top:5px; padding-botto

    dtcms 投票插件 调查问卷

    padding-top:100px;margin-left:10px;margin-right:-10px;} #vote_menu .fixed{position:fixed;width:51px;top:10px;*margin-left:-25px;} 2、将图片 vote.png 添加入 DTcms.Web\templates\green\images 3、将JQ...

    jquery获取div距离窗口和父级dv的距离示例

    jquery中jquery.offset().top / left用于获取div距离窗口的距离,jquery.position().top / left 用于获取距离父级div的距离(必须是绝对定位的div)。 (1)先介绍jquery.offset().top / left css: 代码如下: *{ ...

    jQuery多项选项卡的实现思路附样式及代码

    padding-top:0px; padding-left:0px; position:absolute; } #div1 ul{ margin-top:0px; padding-left:0px; background-color:#ccc; list-style:none; } #div1 ul li{ padding-left:0px; } #div1 ul li input{ ...

    浅谈jQuery中height与width

    jquery中有三个获取element高度的方法,分别是:height(),innerHeight(),outerHeght(bool);同样对应的有三个获取element宽度的方法:width(),innerHeight(),outerHeight(bool),这三个方法分别对应怎样的元素属性,如下...

    jQuery的砸金蛋抽奖代码.zip

    padding-top: 110px; position: relative; width: 660px; } .eggList li { float: left; background: url(images/egg_1.png) no-repeat bottom; width: 391px; height: 268px; cursor: pointer; ...

    相位角.html css+div生成相位角

    css+div生成相位角 三项电流相位角 <script src="https://cdn.bootcss.com/jquery/... margin-top: 200px; width: 300px; height: 300px; background: #eee; border-radius: 100%; position: relative; }

    三星9305收索

    vertical-align:top}#lk{margin:33px 0}#lk span{font:14px "宋体"}#lm{height:60px;line-height:15px}#lh{margin:16px 0 5px;word-spacing:3px}#cp,#cp a{color:#666}#cp .c-icon-icrlogo{width:14px;height:17px;...

    JQuery大转盘

    <!... ...charset="utf-8" /> ... <button id="button" style="margin-top:20px;">来一发 <script src="js/jquery-1.8.2.min.js" type="text/javascript"> <script src="js/init.js" type="text/javascript"></script>

    jQuery实现TAB选项卡切换特效简单演示

    本文实例为大家分享jQuery实现TAB选项卡切换特效,供大家参考,具体内容如下 1、tab切换 on <!...<... ...jQuery tab切换<... margin-top: 50px; } /*清浮动---clearfix*/ .clearfix { *zoom: 1;

    jQuery的手机端九宫格转盘抽奖代码.zip

    <... <head> <meta charset="utf-8">...meta name="viewport" content="width=device-width...main{padding-top: 3em;} table { border-spacing: 0; border-collapse: collapse; text-align: center; }

    jQuery实现的一个tab切换效果内部还嵌有切换

    body{margin-top:10px;margin-left:15px;} #all{border-left:1px solid #ccc;border-right:1px solid #ccc;border-bottom:1px solid #ccc;width:255px;} #title li{float:left;list-style:none;width:50px;border-...

    原生js和jQuery随意改变div属性style的名称和值

    一些简单的例子,用原生js和jQuery实现随意改变div属性,和重置。代码如下: <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>函数传参,改变Div任意属性的值</title...

    Sticky-Stuff:一个用于粘性表头的 jQuery 插件

    ##粘性的东西用于持久表头的 jQuery 插件。入门重置表的 css 并将克隆的标题设置为顶部 table { margin : 0 ; padding : 0 ; border : 0 ;}. stickystuff-cloned { margin-top : 0 ; position : fixed; top : 0 ; z-...

    jquery实现放大镜简洁代码(推荐)

    简介 网上有许多放大镜的jquery的插件,但是用着不是那么得心应手,现在一页代码实现一个放大镜功能,如果需要附加的功能可以手动修改,原理都在注释里 <!...<... ... margin: 0;... margin-top:50px; widt

    jQuery实现随意改变div任意属性的名称和值(部分原生js实现)

    一些简单的例子,用原生js和jQuery实现随意改变div属性,和重置。代码如下: 代码如下: <!DOCTYPE html> <html> <head> <meta charset=”utf-8″/> <title>函数传参,改变Div任意属性的...

    Jquery实现顶部弹出框特效

    Jq制作的页面顶部动态弹出的提示框,可以用于提示信息的显示以及通知信息的显示。 ... <div class=bg></div> <div class=main><i>Jq顶部弹出框</i><span xss=removed title=关闭>X</span></div> ... margin-top:

    jQuery实现简易QQ聊天框

    本文实例为大家分享了jQuery实现简易QQ聊天框的具体代码,供大家参考,具体内容如下 <!...<... <head>...meta charset="UTF-8">...margin: 0;padding: 0;... margin: 0 auto;... margin-top: 20px; } .box

    html、css和jquery相结合实现简单的进度条效果实例代码

    废话不多说了,直接给大家贴代码了,具体代码如下所示: <!DOCTYPE html> <... <head>...jquery实现进度条<... padding:30px;... margin-left:450px;... margin-top:200px;  width:350px;  borde

    jquery实现很酷的网页顶部图标下拉菜单效果

    本文实例讲述了jquery实现很酷的网页顶部图标下拉菜单效果。...http://demo.jb51.net/js/2015/jquery-web-top-ico-show-menu-style-codes/ 具体代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD

Global site tag (gtag.js) - Google Analytics