jQuery one() Method (ok)
https://www.w3schools.com/jquery/event_one.asp
$('.test').one('click',function(){
alert('Sự kiện này chỉ hiển thị một lần.');
});$('body').one('click','.test',function(){
alert('Sự kiện này chỉ hiển thị một lần.');
});.one('Sự kiện',function(){...})
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tiêu đề</title>
<script src="https://code.jquery.com/jquery-latest.js"></script>
<style>
p {
background: blue;
border: 10px outset;
float: left;
height: 50px;
margin: 5px;
width: 50px;
}
</style>
<script>
$(function(){
$('p').one('click',function(){
$(this).css({borderStyle: "inset"});
});
});
</script>
</head>
<body>
<p>P</p>
<p>P</p>
<p>P</p>
<p>P</p>
</body>
</html>.one('Sự kiện','bộ chọn',function(){...})
Last updated