如何在不使用触发器的情况下打开带有标签<button></button>的日期选择器?



我正在尝试更改按钮的工作方式。我希望<input type = "submit">的行为与代码中的<button>一样,而<button>的行为与<input type = "submit">一样。如果我知道如何打开带有<button></button>标记的日期选择器,我想我可以反转它。

<!DOCTYPE html>
<html>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.12.0/moment.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//type submit
$( "#datepicker" ).datepicker();
//type submit
//Click buttom
$("#div1").click(function() {
$("#datepicker").datepicker("show");
});
//Click buttom
});
</script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.css" rel="stylesheet"/>
<button id="div1" >13/04/2020</button>
<br>
<br>
<input type="submit" id="datepicker" value="CAMBIAR FECHA">
<!-- <input type="submit" id="open-datepicker" value="cambiar fecha"> -->
</body>
</html>

目前尚不清楚您遇到了什么问题,也不清楚您正在努力实现什么。您可能需要考虑以下几点。

$(function() {
$("#datepicker").datepicker({
showOn: "button",
buttonText: "13/04/2020"
});
});
.back {
background: #000;
font-weight: 700;
font-size: 50px;
color: #fff;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.12.0/moment.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.css" rel="stylesheet" />
<input type="submit" id="datepicker" value="CAMBIAR FECHA">

相关内容

最新更新