jQuery_review之一行語句搞定表單焦點樣式,jquery_review語句

來源:互聯網
上載者:User

jQuery_review之一行語句搞定表單焦點樣式,jquery_review語句

    眾所周知,各種瀏覽器對於HTML、CSS以及原生JS的支援不盡相同。但是jQuery很好地封裝了各種瀏覽器不同的實現,能夠很好地解決跨瀏覽器的CSS問題。下面就是在review表單操作的時候的一個DEMO,記錄在這個地方,方便後面做項目的時候尋找使用。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>  <script type="text/javascript" src="jquery-1.8.3.js"></script>  <script type="text/javascript">      $(function(){            $("input[type='text']").focus(function(){              $(this).addClass("onfocus");          }).blur(function(){              $(this).removeClass("onfocus");          });      });  </script>  <style type="text/css">      input.onfocus{          border:solid red 2px;          background-color:grey;          }  </style>  </head>  <body>      <form action="#" method="get">          <label for="name">name:</label>              <input type="text" name="name"><br/>          <label for="address">address:</label>              <input type="text" name="address"><br/>          <label for="email">E-mail:</label>              <input type="text" name="email"><br/>          <label for="qq">QQ:</label>              <input type="text" name="qq"><br/>          <input type="button" value="submit"><br/>      </form>  </body></html>  



Jquery語句 在id=“lktable”的表格中添加一行,是這寫嘛?怎寫才正確?

你這樣寫是錯誤的,appendTo用法請參考api
可以這樣
$('#lktable').append("<tr><td>"+m_begin+"</td>"+"<td>"+m_end+"</td>"+"<td>"+m_path+"</td>"+"<td>"+m_num+"</td>"+"</tr>");
 
input 大家知不知道這個怎寫的,滑鼠經過表單時高亮變色,並且焦點落在第一個表單上,最好用jQuery 來寫

$(function(){
$(':text').hover(function(){
$(this).addClass('aa');//aa 為高亮的樣式
},
function(){
$(this).removeClass('aa');
}).first().get(0).focus();
});
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.