jQuery UI Datepicker destroy()方法
jQuery UI由GUI部件、视觉效果和使用HTML、CSS和jQuery实现的主题组成。jQuery UI非常适用于为网页构建UI界面。
在这篇文章中,我们将使用jQuery UI Datepicker destroy()方法来完全移除widget中的datepicker功能。这个方法不接受任何参数,并将元素返回到它的预启动状态。
语法:
$(".selector").datepicker("destroy");
CDN链接:首先,添加你的项目需要的jQuery UI脚本。
<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 Datepicker destroy() 方法的用途。
<!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>
<!-- jQuery code -->
<script>
(function () {
("#GFG").datepicker();
("#btn").on('click', function () {
("#GFG").datepicker("destroy");
});
});
</script>
</head>
<body>
<center>
<h1 style="color: green;">
GeeksforGeeks
</h1>
<h3>jQuery UI Datepicker destroy() Method</h3>
<p>Enter Date: <input type="text" id="GFG"></p>
<input type="button" id="btn"
style="padding: 5px 15px;"
value="Destroy the Widget">
</center>
</body>
</html>
输出: