2017-03-24 14 views
0

enter image description herejQuery的日曆沒有文本框

我試圖從jQuery日曆,我怎麼隱藏文本,以便有剛的日曆圖標刪除文本框。

<!doctype html> 
 
<html lang="en"> 
 
<head> 
 
    <meta charset="utf-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <title>jQuery UI Datepicker - Icon trigger</title> 
 
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> 
 
    <link rel="stylesheet" href="/resources/demos/style.css"> 
 
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script> 
 
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> 
 
    <script> 
 
    $(function() { 
 
    $("#datepicker").datepicker({ 
 
     showOn: "button", 
 
     buttonImage: "images/calendar.gif", 
 
     buttonImageOnly: true, 
 
     buttonText: "Select date" 
 
    }); 
 
    }); 
 
    </script> 
 
</head> 
 
<body> 
 

 
<p>Date: <input type="text" id="datepicker"></p> 
 

 

 
</body> 
 
</html>

+0

雖然這是可以做到的,要存儲選定的日期在哪裏? –

+0

@RoryMcCrossan我不想在日曆的任何地方顯示任何日期,只需點擊彈出窗口 – user580950

+0

是的 - 但是您想如何處理用戶從日期選擇器中選擇的值?它需要存儲在某個地方 –

回答

2

你可以簡單地設置文本框類型爲「隱藏」,然後在框中將不顯示,但你仍然要保存價值的地方。

<input type="hidden" id="datepicker"> 
2

添加這個CSS:

#datepicker{ 
display:none 
}