I am working on Jquery,Right now i am getting "datepicker" on "input type text",but i want to display that datepicker on button click,how can i do this ? Here is my current code
<head>
<link href="https://code.jquery.com/ui/jquery-ui-git.css" rel="stylesheet" type="text/css" />
<script src="https://code.jquery.com/jquery-git.js"></script>
<script src="https://code.jquery.com/ui/jquery-ui-git.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Initialize the datepicker and display a button panel underneath the calendar.</title>
</head>
<body>
<p>Pick a date:</p>
<p><input type="text" id="datepicker1" /></p>
<button id="bt">Date</button>
</body>
<script>
$('#bt').click(function(){
$( "#datepicker1" ).datepicker({
showButtonPanel: true
});
});
</script>
3
Answers
use this code for open a date picker on click
use this code for open a date picker on button click
Based on the following: https://jqueryui.com/datepicker/#icon-trigger you can use the following example:
The button is added dynamically and retains the style format you showed with CSS.