Uncaught TypeError: Cannot read property 'top' of undefined
See original GitHub issueUsing the latest version of the datepicker I’m getting this error. Following my code:
<div class="control-group">
<label class="control-label" for="question-15">Start Date:</label>
<div class="controls">
<input type="text" name="start_date[response]" value="" id="question-15" class="required date">
</div>
</div>
<div class="control-group">
<label class="control-label" for="question-16">End Date:</label>
<div class="controls">
<input type="text" name="end_date[response]" value="" id="question-16" class="required date">
</div>
</div>
<script>
$(function(){
$('.date').datepicker();
});
</script>
When I attempt to do this, I’m getting the following error: Uncaught TypeError: Cannot read property ‘top’ of undefined in bootstrap-datepicker.js on line 148
Issue Analytics
- State:
- Created 11 years ago
- Comments:15 (1 by maintainers)
Top Results From Across the Web
Uncaught TypeError: Cannot read property 'top' of undefined
This malfunction occurs because your href is set to # inside of your <a> tag. Basically, your app is trying to find href...
Read more >TypeError: Cannot read property 'top' of Undefined in JS
The "Cannot read property 'top' of undefined" error occurs when trying to access the top property on an undefined value. To solve the...
Read more >Uncaught TypeError: Cannot read property 'top' of undefined
'Undefined' is the property of the global object. This error occurs in Chrome Browser when you read a property or call a method...
Read more >Uncaught TypeError: Cannot read property 'top' of undefined
I have use one page scroll but not working in live. custom.js:73 Uncaught TypeError: Cannot read property 'top' of undefined at HTMLAnchorElement.
Read more >Uncaught TypeError Cannot read property top of undefined
Here this line of code: var contentNav = $('.content-nav').offset().top; is firing an error: "Uncaught TypeError: Cannot read property 'top' ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The documentation doesn’t specify this very well, but if you get this error, this is what you’re doing wrong: You have an element with a ‘date’ class, but that element doesn’t contain an element with contains an ‘add-on’ class.
If you have a single input element that you want to be a date field all on it’s own, it should NOT have the ‘date’ class, but SHOULD have the attribute data-date-format. For example, the following markup is correct:
The following markup is incorrect:
If you have a div with the ‘date’ class, then it needs a contained element that has the ‘add-on’ class. For example:
In other words, when you get this error, it’s basically saying “Hey the ‘date’ class means that you want to use this calendar icon thing, but I can’t find the class with the ‘add-on’! Fix it!” But of course the error message isn’t very helpful and could be improved.
I tried to explain in my comment on February 27, 2013, but I realize how that my explanation was pretty terrible.
Same issue for jQuery v1.10.1 , and same solution: using class different than ‘date’ make it working.