jQuery—一些常见方法(3)【width(),innerWidth(),outerWidth()】
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> <script src="../../jq-practice/jq/jquery-2.2.1.min.js"></script> <script> $(function(){ alert($('div').width()); //width alert($('div').innerWidth()); //width+padding alert($('div').outerWidth()); //width+padding+border alert($('div').outerWidth(true)); //width+padding+border+margin }); </script> </head> <body> <div style="width: 100px; height: 100px; padding: 10px; border: 4px solid red; margin: 5px; background: blue;" ></div> </body> </html>