jQuery UI Spinner isValid()方法
jQuery UI由GUI部件、视觉效果和使用HTML、CSS和jQuery实现的主题组成。 jQuery UI非常适合为网页构建UI界面。
在这篇文章中,我们将看到如何使用jQuery UI spinner中的isValid()方法。这个方法返回Spinner的值是否有效,因为它的min, max, 和step。
语法:
var isValid = $( ".selector" ).spinner( "isValid" );
参数:该方法不接受任何参数。
返回值:该方法返回旋转器实例对象。
CDN链接:首先,添加你的项目需要的jQuery UI脚本。
<link rel=”stylesheet” href=”//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css”>
<script src=”//code.jquery.com/jquery-1.12.4.js”></script>
<script src=”//code.jquery.com/ui/1.12.1/jquery-ui.js”></script>
例子:这个例子描述了jQuery UI Spinner isValid()方法。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title> jQuery UI Spinner isValid() Method </title>
<link rel="stylesheet" href=
"//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<script src=
"//code.jquery.com/jquery-1.12.4.js">
</script>
<script src=
"//code.jquery.com/ui/1.12.1/jquery-ui.js">
</script>
<style>
h1 {
color: green;
}
#divID {
width: 600px;
}
</style>
</head>
<body>
<center>
<h1>GeeksforGeeks</h1>
<h2>jQuery UI Spinner isValid() Method</h2>
<input id="divID">
<br><br>
<input type="button" id="btn"
value="Check Spinner is Valid"
style="padding: 5px 15px;">
</center>
<script>
(function () {
("#divID").spinner();
("#btn").on('click', function() {
var isValid =("#divID").spinner("isValid");
alert("Spiner Value: " + isValid);
});
});
</script>
</body>
</html>
输出: