清空input框的內容


清楚指定的input框中的值
$("input[name=' *** ']").val("").focus(); // 清空並獲得焦點


一鍵清空input框裏的所有內容
 <html>
 <head>
  <title></title>
     <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> 
<script>   
function delWholeInput(obj) {
    evt = event || window.event;
    if (evt.keyCode.toString() == "8" || evt.keyCode.toString() == "46" ){
        if ($('#' + obj).css('text-decoration') != "none") {
         document.getElementById(obj).value = "";       
        $('#' + obj).css('text-decoration', 'none');
        } 
    }
}</script> 
 </head>
 <body> 
<input type="text" id="t1" style="text-decoration: underline;"  οnkeydοwn="delWholeInput(this);"/> 
 </body>
 </html>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章