html標(biāo)簽中的this使用介紹

字號(hào):


    代碼如下:
    <html>
    <head>
    <script type="text/javascript">
    function showHint(str){
    alert(str) ;
    }
    </script>
    </head>
    <body>
    <input type="text" onkeyup="showHint(this.value)"/> <!--此處,在html標(biāo)簽中的this代表的是此標(biāo)簽-->
    </body>
    </html>
    運(yùn)行結(jié)果為:當(dāng)通過鍵盤向文本框中輸入字符后,當(dāng)按鍵抬起時(shí)(即當(dāng)keyup事件發(fā)生后),會(huì)顯示按下的字符。