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

jQuery ??

jQuery?? HTML ??? ??? ???? ??? ??? ????.


jQuery DOM ??

jQuery?? ?? ??? ??? DOM? ???? ?????.

jQuery? ??? ??? ?? ????? ??? ? ?? ??? DOM ?? ???? ?????.


DOM = ?? ?? ??

DOM? HTML ? XML ??? ????? ?? ??? ?????.

"W3C ?? ?? ??? ????? ????? ??? ???? ????? ????? ? ??? ?? ??? ? ?? ???? ????????. "


??? ???? - text(), html() ? val()

DOM ??? ?? ? ?? ???? ???? jQuery ??:

  • text( ) - ??? ???? ????? ?????. selected element

  • html() - ??? ??(HTML ?? ??)? ??? ?? ?? ??

  • val() - ?? ??? ? ?? ?? ??

?? ???? ??? ?????. jQuery text() ? html() ???? ?? ???? ?????:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
    </script>
    <script>
        $(document).ready(function(){
            $("#btn1").click(function(){
                alert("Text: " + $("#test").text());
            });
            $("#btn2").click(function(){
                alert("HTML: " + $("#test").html());
            });
        });
    </script>
</head>
<body>
<p id="test">這是段落中的 <b>粗體</b> 文本。</p>
<button id="btn1">顯示文本</button>
<button id="btn2">顯示 HTML</button>
</body>
</html>

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


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

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
    <script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
    </script>
    <script>
        $(document).ready(function(){
            $("button").click(function(){
                alert("值為: " + $("#test").val());
            });
        });
    </script>
</head>
<body>
<p>名稱: <input type="text" id="test"></p>
<button>顯示值</button>
</body>
</html>

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


?? ???? - attr()

jQuery attr() ???? ???? ?? ?? ?????.

?? ???? ???? href ?? ?? ???? ??? ?????.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
    </script>
    <script>
        $(document).ready(function(){
            $("button").click(function(){
                alert($("#tr").attr("href"));
            });
        });
    </script>
</head>
<body>
<p><a href="http://ipnx.cn" id="tr">PHP中文網(wǎng)</a></p>
<button>顯示 href 屬性的值</button>
</body>
</html>

????? ???? ??? ???



???? ??
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("#btn1").click(function(){ alert("Text: " + $("#test").text()); }); $("#btn2").click(function(){ alert("HTML: " + $("#test").html()); }); }); </script> </head> <body> <p id="test">這是段落中的 <b>粗體</b> 文本。</p> <button id="btn1">顯示文本</button> <button id="btn2">顯示 HTML</button> </body> </html>