700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > jquery获取元素宽高

jquery获取元素宽高

时间:2019-07-03 23:40:35

相关推荐

jquery获取元素宽高

前言

jquery获取元素宽高

<!DOCTYPE html><html lang="zh" ><head><meta charset="utf-8"><style>li {margin: 10px;padding: 5px;border: 2px solid #666;width: 800px;height: 100px;display: block;}li:first-child {background-color:#0fc;}li:nth-child(2) {background-color:#cf0;}li:nth-child(3) {background-color:#cfc;}li:last-child {background-color:#3f0;}li:nth-last-child(2) {background-color:#333;}</style></head><body class="white-bg"><ul><li></li><li></li><li></li><li></li><li></li></ul><script src="/jquery/3.5.1/jquery.min.js"></script><script type="text/javascript">$(function(){$("li:eq(0)").text("width:" + $("li:eq(0)").width() + ",innerWidth:" + $("li:eq(0)").innerWidth() + ",outerWidth:" + $("li:eq(0)").outerWidth() + ",outerWidth(true):" + $("li:eq(0)").outerWidth(true));$("li:eq(1)").text("width:" + $("li:eq(1)").height() + ",innerHeight:" + $("li:eq(1)").innerHeight() + ",outerHeight:" + $("li:eq(1)").outerHeight() + ",outerHeight(true):" + $("li:eq(1)").outerHeight(true));});</script></body></html>

参考

/goloving/p/7113567.html

/width/

/innerWidth/

/outerWidth/

/

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。