jQuery UI Spinner stepUp()方法
jQuery UI由GUI小部件、视觉效果和使用jQuery、CSS和HTML实现的主题组成,jQuery UI对于构建网页的UI界面非常有用。jQueryUI的旋转器可以帮助我们使用向上和向下的箭头来增加和减少输入元素的值。在这篇文章中,我们将看到如何在jQuery UI滑块中使用stepUp()方法。stepUp()方法是用来增加jQuery UI spinner中指定步数的值。这个方法可以调用三个元素开始,停止和旋转。
语法:
$(".selector").spinner("stepUp", steps);
参数:该方法接受一个上面提到的和下面描述的单一参数。
- steps。该参数持有要递增的步骤数。
CDN链接:首先,添加jQuery UI脚本的CDN链接,为你的任务所需。
<link href = “https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css” rel = “stylesheet”>
<script src = “https://code.jquery.com/jquery-1.10.2.js”></script>
<script src = “https://code.jquery.com/ui/1.10.4/jquery-ui.js”></script>
例子1:在这个例子中,我们按给定的步数增加数值,每一步的数值都增加1。
<!Doctype html>
<html lang = "en">
<head>
<meta charset = "utf-8">
<link href =
"https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css"
rel = "stylesheet" />
<script src =
"https://code.jquery.com/jquery-1.10.2.js">
</script>
<script src =
"https://code.jquery.com/ui/1.10.4/jquery-ui.js">
</script>
<style type = "text/css">
#gfg input {width: 100px}
</style>
<script>
(function() {
("#gfg").spinner();
('button').button();
('#gfg1').click(function () {
$("#gfg").spinner("stepUp");
});
});
</script>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h2>jQuery UI | spinner stepUp method</h2>
<input id = "gfg" />
<br/>
<button id = "gfg1">+1</button>
</body>
</html>
输出: