jQuery学习尺寸

 

1.jQuery总结:show(),hide(),toggle(),slideUp(),slideDown(),slideToggle(),animate(),slide Window(滑动窗口)

2.用jQuery实现二级菜单

●代码如下:

<script type="text/javascript">
    $(function(){
        $(".navmenu").mouseover(function(){
            $(this).children("ul").show();
            //$(this).children("ul").css({display:'block'})
        })
        $(".navmenu").mouseout(function(){
            $(this).children("ul").hide();
            //$(this).children("ul").css({display:'none'})
        })
    })
</script>

●代码实现:

  

3.jQuery尺寸图解

<1>和css样式差不多

                   

<2>通过jQuery获取元素的尺寸

●代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>jQuery尺寸</title>
    <script src="jquery-1.9.1.min.js"></script>
    <script>
        $(document).ready(function(){
            $('button').click(function(){
                var txt =""
                txt += 'div的宽度是:'+$('#div1').width()+'px'+'<br/>';
                txt += 'div的宽度是:'+$('#div1').height()+'px'+'<br/>';
                txt += 'div宽度,包括内边距:'+$('#div1').innerWidth()+'px'+'<br/>';
                txt += 'div宽度,包括内边距:'+$('#div1').innerHeight()+'px'+'<br/>';
                txt += 'div宽度,包括内边距和边框:'+$('#div1').outerWidth()+'px'+'<br/>';
                txt += 'div宽度,包括内边距和边框:'+$('#div1').outerHeight()+'px'+'<br/>';
                txt += 'div宽度,包括内边距和边框、外边距:'+$('#div1').outerWidth(true)+'px'+'<br/>';
                txt += 'div宽度,包括内边距和边框、外边距:'+$('#div1').outerHeight(true)+'px'+'<br/>';
 
                $("#div1").html(txt)
            })
        })
    </script>
</head>
<body>
<div id="div1" style="height: 200px;width: 200px;padding:10px;border: 5px solid brown ;margin: 1px"></div>
<button>显示div元素的尺寸</button>
</body>
</html>

 

●代码实现:

    点击“显示”→→→     

 

●涉及的知识点

width():设置或返回元素的宽度(不包括内边距,边框,外边距)

height():设置或返回元素的高度(不包括内边距,边框,外边距)

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值