Home > Web Front-end > JS Tutorial > body text

Jquery implementation example of Div moving up and down_jquery

WBOY
Release: 2016-05-16 16:51:30
Original
1165 people have browsed it
复制代码 代码如下:

$(this).ready(function() {
$(".up").each(function() {
$(this).click(function() {
var $tr = $(this).parents("li");
if ($tr.index() != 0) {
$tr.prev().before($tr);
}
});
});
var trLength = $(".down").length;
$(".down").each(function() {
$(this).click(function() {
var $tr = $(this).parents("li");
if ($tr.index() != trLength) {
$tr.next().after($tr);
}
});
});
$("a[name='up']").click(function() {
if ($("input[name='rule']:checked").size() > 1) {
alert("只能选择一项进行上下移操作!");
return;
}
$("input[name='rule']:checked").each(function() {
var $div = $('#rule_' $(this).val());
if ($div.index() != 0) {
$div.prev().before($div);
}
});
});
$("a[name='down']").click(function() {
if ($("input[name='rule']:checked").size() > 1) {
alert("只能选择一项进行上下移操作!");
return;
}
$("input[name='rule']:checked").each(function() {
var $div = $('#rule_' $(this).val());
if ($('#rule_' (parseInt($(this).val()) 1)).html() != null) {
$div.next().after($div);
}
});
});
});
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template