01 May 2017

JQuery: Event keypress Bắt sự kiện bấm Enter trên bàn phím khi nhập trên thẻ Input

Bắt sự kiện enter trên thẻ input
JavaScript 2017
<input type="text" id="itemID">

$('#itemID').keypress(function(event) {
 if (event.keyCode == 13 || event.which == 13) {
         event.preventDefault();  //Không cho submit from bạn có thể bỏ nều k cần
         //Các câu lệnh Logic sẽ thực hiện ở đây        
    }
});

Related Posts:

  • jQuery: Date picker sử dụng jQuery Input type text date Format dd/mm/yyyy Date picker với jQuery jQuery 2017 <html> <head> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> <script src="http://code.jq… Read More
  • jQuery Effects jQuery Fade jQuery 2016 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#… Read More
  • jQuery HTML jQuery Get jQuery 2016 Click #btn1 hiển thị nội dung nằm trong #test là kiểu text Click #btn2 hiển thị nội dung nằm trong #test là kiểu html <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.m… Read More
  • jQuery Traversing jQuery Ancestors jQuery 2016 jQuery parent() //Chỉ hiển thị CSS thẻ <li> bao bọc thẻ <span> <style> .ancestors * { display: block; border: 2px solid lightgrey; color: lightgrey; … Read More
  • jQuery: Validate form đơn giản nhất với jQuery Validate thường với jQuery jQuery 2017 $(document).ready(function() { $("#save").on('click', function() { // BƯỚC 1: Lấy dữ liệu từ form var soHoaDon = $('#soHoaDon').val(); var ng… Read More

1 nhận xét:

 

BACK TO TOP

Xuống cuối trang