【发布时间】:2016-05-20 05:21:58
【问题描述】:
您好,我有一种情况,当输入元素被聚焦时,我需要绑定 jquery UI datepicker({}) 函数。我无法使用下面的代码实现它,所以请各位帮忙,我该如何绑定输入元素获得焦点时的 datepicker 函数
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<title> Jquery UI Date Picker </title>
</head>
<body>
<input type="text" id="date" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script>
//$('#date').datepicker({});
$('#date').on('foucs',function(){
$(this).datepicker({});
});
</script>
</body>
</html>
【问题讨论】:
-
其实焦点的时候不需要datepicker,只需要设置input readonly,像这样:jsfiddle.net/ananis/sdq26rhs
-
我必须在焦点上绑定功能
标签: jquery jquery-ui jquery-ui-datepicker