I am trying to get bootstrap datepicker to work but it does not even show up.
http://www.eyecon.ro/bootstrap-datepicker/
<link href="~/Css/datepicker.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.8.1.js" type="text/javascript"></script>
<script src="~/Scripts/bootstrap-datepicker.js" type="text/javascript"></script>
<script type="text/javascript">
$("#datepicker").datepicker();
</script>
<input id="datepicker" value="10/22/2011" />
I am using bootstrap 2.1.1
It looks like you’re trying to initialize a datepicker when there’s no
#datepickerelement in DOM yet (the correspondinginputfollows<script>element, not vice versa).As
$('#datepicker')will still return a jQuery-wrapped object (notnull!), no error will be thrown.To solve this, either make this call when DOM is loaded:
or move this script into very end of
<body>element.I’d choose the first option; moving all the DOM-ready actions into the same
$(function() { ... });wrapper as well.