<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style>
textarea {
width:200px;height:100px;
}
</style>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<meta charset="utf-8" />
</head>
<body>
<div> <span class="xx">向下</span><span class="xs">向上</span></div>
<br />
<hr />
<textarea id="id1">
123。
</textarea>
<script>
$(function () {
var $er = $("#id1");
$(".xs").click(function () {
if (!$er.is(":animated")) {
if ($er.scrollTop() > 50) {
$er.animate({ scrollTop: "-=50" }, 1000);
}
}
});
$(".xx").click(function () {
if (!$er.is(":animated")) {
if ($er.scrollTop() < 500) {
$er.animate({ scrollTop: "+=50" }, 1000);
}
}
});
})
</script>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style>
textarea {
width:200px;height:100px;
}
</style>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<meta charset="utf-8" />
</head>
<body>
<div> <span class="xx">向下</span><span class="xs">向上</span></div>
<br />
<hr />
<textarea id="id1">
123。
</textarea>
<script>
$(function () {
var $er = $("#id1");
$(".xs").click(function () {
if (!$er.is(":animated")) {
if ($er.scrollTop() > 50) {
$er.animate({ scrollTop: "-=50" }, 1000);
}
}
});
$(".xx").click(function () {
if (!$er.is(":animated")) {
if ($er.scrollTop() < 500) {
$er.animate({ scrollTop: "+=50" }, 1000);
}
}
});
})
</script>
</body>
</html>