亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

jQuery? ?? ??? ????.

?? ?? ??

??, ?? ? CSS ???? ???? ??? ?? ?? ?? ??? ?? ? ??? ?? ??? ?????.

<!doctype html>
<html>
<head>
  <meata charset="utf-8"/>
  <title>get object width</title>
  <script src="jquery-1.11.2.min.js"></script>
  <script>
    $(function() {
      alert("attr(\"width\"):" + $("#testDiv").attr("width")); //undifined
      alert("css(\"width\"):" + $("#testDiv").css("width")); //auto(ie6) 或 1264px(ff)
      alert("width():" + $("#testDiv").width()); //正確的數(shù)值 1264
      alert("style.width:" +  $("#testDiv")[0].style.width); //空值
    })
  </script>
</head>
<body>
  <div id="testDiv">test text</div>
</body>
</html>

??? ???? ??? ???? attr? ?????. div? ??? ???? ??? ??? "?? ??"? ???? ???? ???? ?????. style ??? ?? css() ???? ???? ?? ? ???, ?? ?????? ???? ??? ????. IE6? auto? ????? FF? ??? ?? ????? ? ?? "px"? ????. ??? jQuery? px ?? ??? ?? ???? width() ???? ?????.

? ??? ?? ???? jQuery? ????? ???? ??? ???? ???? ??? ?????. ?? ?? width()? ???? ??? ??? ?? ? ?? width(val)? ??? ??? ???? ? ?????. .

?? ??? ???? ??? ?? ?? ?? ?? ? ????:

HeightAndWidth.jpg

1. ?? ? ?? ?? Height ? Width

??? ??? ??? ?? ? ??, "??" "? ???? ???. "??"? ??/??? ? ?? ?? ?? ??:

division.jpg

outerWidth? ?? ?? ??? ???? ?? ? ????? ??? ? ????. ?.

? ??? ? ??? ???? ??? ???? ????? ?????. ????? ??? ?? ??? ??? ??? ?????.

2. ?? ?? ?? ?? ??

?? ?? ??? ??? ?? ??????? ?? ??? ???? ???? ??? ??? ?????? ?? ??? ????.

??? ??? ???? ?? ???? ???? ??? ??? ????. jQuery? ??? ?? ?? ??? ?????.

Positioning.jpg

???? ??
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <script src="http://code.jquery.com/jquery-3.1.1.min.js"></script> </head> <style> body{font-family: "微軟雅黑";width: 980px; margin: 0 auto; text-align: center;} .box{ width: 300px; height: 300px; background: green; border: 1px solid #e6e6e6; line-height: 200px; position: absolute; } button{ border: none; background: green; width: 125px; height: 50px; line-height: 50px; color: #fff; font-size: 16px; margin-top: 50px; font-family: "微軟雅黑"; } </style> <body> <button id="btn1">顯示text</button> <button id="btn2">顯示html</button> <button id="btn3">顯示輸入內(nèi)容</button> <p id="text">這是要顯示<b>粗體</b>的節(jié)奏</p> <br /> <input id="input" value="買房子"> <script> $(document).ready(function(){ $("#btn1").click(function(){ alert("Text: " + $("#text").text()); }); $("#btn2").click(function(){ alert("HTML: " + $("#text").html()); }); $("#btn3").click(function(){ alert("Value: " +$("#input").val()); }); }); </script> </body> </html>