Định nghĩa và sử dụng .focusin() trong jQuery

.focusin(): Xử lý một sự kiện "focusin" (xác nhận một focus).

Cấu trúc .focusin() trong jQuery

Đã được thêm vào từ phiên bản 1.4

.focusin(function(){...});

$('p').focusin(function(){

    $(this)find('span').css('display','inline');
});

.focusin(function(){...});

Html viết:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tiêu đề</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style>
input { color: #ccc; }
</style>
<script>
$(function(){
    $('p').focusin(function(){
        $(this).find('input').css('color','#000');
    });
});
</script>
</head>

<body>
<p><input type="text" value="Nhập text" />
<p><input type="text" value="Nhập text" />
</body>
</html>

Hiển thị trình duyệt:

Click vào trường input để thấy kết quả.

Viết câu trả lời

Drop Images

0 Bình luận