jQuery UI spinner变化事件
jQuery UI由GUI部件,视觉效果和使用jQuery,CSS和HTML实现的主题组成。jQuery UI对于构建网页的UI界面非常有用。在这篇文章中,我们将看到如何在jQuery UI滑块中使用变化事件。当旋转器的值发生变化并且输入不再集中在jQuery UI旋转器上时,变化事件就被触发了。
语法:
$( ".selector" ).spinner({
change: function( event, ui ) {}
});
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>
下面的例子说明了jQuery UI Spinner的变化事件。
示例:
<!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({
change: function (event, ui) {
console.log("change has occurred");
},
});
});
</script>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h2>jQuery UI | spinner change event</h2>
<input id="gfg" />
</body>
</html>
输出: