一键删除input里全部内容

来源:互联网 发布:上海网络教育哪里报名 编辑:程序博客网 时间:2024/06/04 18:18

 <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;"  onkeydown="delWholeInput(this);"/> 
 </body>
 </html>

 

//input文字添加下划线

$('#' + obj).css('text-decoration', underline);

0 0