Hiệu ứng Transfer trong jQuery
Miêu tả
Hiệu ứng Transfer có thể được sử dụng với phương thức effect(). Nó chuyển hình dáng của một phần tử cho phần tử khác. Rất hữu ích khi bạn tương tác giữa hai phần tử.
Cú pháp
Sau đây là cú pháp để sử dụng hiệu ứng Transfer trong jQuery:
selector.effect( "transfer", {arguments}, speed );
Tham số
Chi tiết tham số được sử dụng để tạo hiệu ứng Transfer trong jQuery:
className − Tên lớp tùy chọn mà phần tử chuyển dời sẽ nhận.
to − jQuery selector, phần tử để chuyển tới.
Ví dụ
Sau đây là ví dụ đơn giản minh họa cách sử dụng của hiệu ứng Transfer trong jQuery:
<html>
<head>
<title>The jQuery Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$("div").click(function () {
var i = 1 - $("div").index(this);
$(this).effect("transfer",{ to: $("div").eq(i) }, 500);
});
});
</script>
<style>
div.green { margin: 0px; width: 100px; height: 80px; background: green; border: 1px solid black; position: relative; }
div.red { margin-top: 10px; width: 50px; height: 30px; background: red; border: 1px solid black; position: relative; }
/* Following is required to show border while transferring.*/
.ui-effects-transfer { border: 2px solid black; }
</style>
</head>
<body>
<p>Click any of the squares:</p>
<div class="green"></div>
<div class="red"></div>
</body>
</html>
Nó sẽ cho kết quả:
Công cụ giáo viên (2048.VN)
Tạo- trộn đề thi miễn phí từ file PDF, Word, Giao bài nhanh chóng, Hoàn toàn Free
Các bài học jQuery khác tại VietJack:
Dành cho bạn
Công cụ giáo viên
- Tạo đề online từ PDF / Word
- Trộn nhiều mã đề, in Offline
- Giao bài online, Quản lí lớp học

