2017-08-07 10 views
2

日付ピッカーの画像に添付されているTodayの日付を表示したいとします。現在の日付を表示するJquery Datepicker

$(document).ready(function() {    

     $("#TextBox1").datepicker({ 
      changeMonth: true, 
      changeYear: true, 
      showOn: "button", 
      buttonImage: "../calendar_up.gif", 
      buttonImageOnly: true, 
      buttonText: "Select date", 
      showOtherMonths: true, 
      selectOtherMonths: true 
     }); 

enter image description here

任意の構成は、これを達成するために利用できるのですか?

TIA

+0

彼は入力ピッカーのドロップダウンボックスで質問していますが、入力テキストボックスの値ではありません – Selvakumar

答えて

1

は、私が見つけたnoオプションはありませんが、あなたは、もちろん、それはピッカーの一部であるようにそれが見えるようにすることができます:

var $datepicker = $("#datepicker").datepicker({ 
 
    changeMonth: true, 
 
    changeYear: true, 
 
    showOn: "button", 
 
    buttonImage: "../calendar_up.gif", 
 
    buttonImageOnly: true, 
 
    buttonText: "Select date", 
 
    showOtherMonths: true, 
 
    selectOtherMonths: true 
 
}); 
 

 
var $today = $datepicker.append("<div class='ui-widget ui-widget-content ui-helper-clearfix ui-corner-bottom' style='display:block;padding:2px;position:relative;top:-2px'>TODAY: " + formatDate(new Date()) + "</div>"); 
 

 
var $datePickerInner = $(".ui-datepicker"); 
 

 
$today.css("width", $datePickerInner.width() + 9.4 + "px"); 
 
$datePickerInner.removeClass('ui-corner-all').addClass('ui-corner-top'); 
 

 
function formatDate(date) { 
 
    return (date.getMonth() + 1).toString() + '/' + date.getDate().toString() + '/' + date.getFullYear().toString(); 
 
}
<!doctype html> 
 
<html lang="en"> 
 

 
<head> 
 
    <meta charset="utf-8"> 
 
    <title>datepicker demo</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> 
 
</head> 
 

 
<body> 
 
    <div id="datepicker"></div> 
 
</body> 
 

 
</html>

+0

ありがとう! –

0

あり日付ピッカーで現在の日付を表示するオプションはありませんが、あなたは、現在の日付に移動するには下のボタンを持つことができます。

$("#datepicker").datepicker({ 
     showButtonPanel: true 
}); 

チェックこのリンクhttps://jqueryui.com/datepicker/#buttonbar

+0

私は$( ".ui-datepicker-current" ).text(今日)もしあなたが欲しいなら – mplungjan

関連する問題