搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
JavaScript
jQuery 教程
jQuery 操作方法
源代码
清空
点击运行
<!DOCTYPE html> <html> <title>jQuery outerWidth(true)获取宽度内边距+边框+外边距示例 - 基础教程(div.cn)</title> <head> <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("div").click(function(){ let w = $(this).outerWidth(true); let h = $(this).outerHeight(true); $(this).html("Outer width [+margin]:" + w + "<br>" + "Outer height [+margin]: " + h); }); }); </script> <style> div { width: 300px; height: 100px; margin: 5px; padding: 10px; border: 3px solid lightgreen; background-color: rgba(144, 238, 144, .4); } </style> </head> <body> <div>单击此DIV获取外部宽度/高度(包括内边距,边框和外边距)</div> </body> </html>
运行结果