jquery.datetimepicker中报错Cannot read property 'top' of undefined
今天在项目里用到一个jQuery的时间插件,一开始自己写的测试demo完全么的问题
但当我把它放到项目里时问题来了,报了一个错:Cannot read property 'top' of undefined
html代码是这样的:↓
<div class="inputLine" >
<input type="text" id="portInDate" placeholder="Expected Port-in Date" value="">
<i class="date"></i>
</div>
点到时间库里看了一下
大概意思就是jquery获取到该元素的offset()里没有top这个属性,也就是获取不到该元素距离文档顶部的距离
这是为什么呢?
input外层div的position属性是relative
div中position:relative与position:absolute的区别
position:absolute是通过left和top定位的,而position:relative是通过margin-left等定位的,所以子元素获取不到top属性。
然后我把代码改了一下↓把id放在了div上
<div class="inputLine" id="portInDate">
<input type="text" placeholder="Expected Port-in Date" value="">
<i class="date"></i>
</div>
然后运行
good
jquery.datetimepicker中报错Cannot read property 'top' of undefined的更多相关文章
- 小程序 for循环 报错 Cannot read property 'total' of undefined
for循环一直报错 Cannot read property 'total' of undefined,但total在起初是有定义的,后来找到了问题,是i<=的问题,改为<不报错了. i ...
- datatables 多一列报错Cannot read property 'sWidth' of undefined(…)/少一列报错Cannot read property 'style' of undefined(…)
datatables 多一列报错Cannot read property 'sWidth' of undefined(…)/少一列报错Cannot read property 'style' of u ...
- vue.config.js报错cannot set property "preserveWhitespace" of undefined
vue.config.js报错cannot set property "preserveWhitespace" of undefined 最近在项目中配置webpack,由于vue ...
- [Element-UI] 使用Element-UI的DateTimePicker组件报错:Cannot read property 'getHours' of undefined
使用Element-UI组件的DateTimePicker,如下: <template> <div class="block"> <span clas ...
- echarts报错Cannot read property 'features' of undefined
引入地图的时候 echarts2报错: Uncaught Error: [MODULE_MISS]"echarts/src/util/mapData/params" is not ...
- UEditor使用报错Cannot set property 'innerHTML' of undefined
仿用UEditor的setContent的时候报错,报错代码如下Uncaught TypeError: Cannot set property ‘innerHTML’ of undefined.调试u ...
- Vue tools开发工具报错Cannot read property '__VUE_DEVTOOLS_UID__' of undefined
使用 vue tools 开发工具,不显示调试面板中的组件,点击控制台报错: Cannot read property 'VUE_DEVTOOLS_UID' of undefined 在 main.j ...
- 使用vue-preview报错Cannot read property 'open' of undefined
最近在做一个vue项目中时,需要使用vue-preview插件制作缩略图,首先在终端使用npm i vue-preview -S指令安装了vue-preview插件,然后在main.js中,导入并引用 ...
- Chrome下使用百度地图报错Cannot read property 'minZoom' of undefined
问题:工作中在Google chome下面的js console里面测试百度地图API var map = new BMap.Map("container"); map.cente ...
随机推荐
- QT透明显示文字
实现效果: 代码: #ifndef IMAGINIST_H #define IMAGINIST_H #include <QtWidgets/QWidget> #include <Qt ...
- tricky c++ new(this)
题目如下:问下列代码的打印结果为0吗? #include <stdlib.h> #include <iostream> using namespace std; struct ...
- session学习总结【session原理、应用、与cookie区别】
session原理 session也是一种记录浏览器状态的机制,但与cookie不同的是,session是保存在服务器中. 由于http是无状态协议,当服务器存储了多个用户的session数据时,如何 ...
- eclipse运行python 安装pydev 版本匹配问题
Eclipse 4.5, Java 8: PyDev 5.2.0 PyDev 5.2.0 版本路径:https://dl.bintray.com/fabioz/pydev/5.2.0 1.安装时注意: ...
- 一、Mongodb安装和配置
简介 MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案. MongoDB是一个介于关系数据库和非关系数据库之间的产品. Mongod ...
- Golang定时任务简单实现
下载cron包: go get github.com/robfig/cron 开启一个定时: 根据cron表达式进行时间调度,cron可以精确到秒,大部分表达式格式也是从秒开始. c := cron. ...
- Elemetary OS deepin-wine 版 微信 和 企业微信 输入框字体显示异常解决
Elemetary OS deepin-wine 版 微信 和 企业微信 输入框字体显示异常解决 最近体验了Elementary OS 这个系统, 话说我之前都是用的Manjora 的各个桌面版, 突 ...
- ## springboot 下策略模式的简单使用
1.灵魂三问 接手前人(已跑路)项目快乐否? 前人项目不写注释懵逼否? 一个方法中一堆if/else,且业务判断条件用简单数字(或英文字母),不带注释,想打人否? 所以,对于上述三个问题,我写 ...
- CNN中的feature map
个人学习CNN的一些笔记,比较基础,整合了其他博客的内容 feature map的理解在cnn的每个卷积层,数据都是以三维形式存在的.你可以把它看成许多个二维图片叠在一起(像豆腐皮竖直的贴成豆腐块一样 ...
- [redis读书笔记] 第二部分 sentinel
1.sentinel的初始化,会制定master的IP和port,然后sentinel会创建向被监视主服务器的命令连接和订阅连接: - 命令连接是用来和主服务器之间进行命令通信的 - 订阅连接,用于 ...