javascript - jQuery中可以获取到图片的高度却无法获取宽度
问题描述
$(document).ready(function() {
ko.validation.init({ errorElementClass: ’has-error’, insertMessages : true});ko.validation.registerExtenders();var dataUrl = {imgUrl : ’/api/advertise/advertisepost’ }, loopPictures = $('.loopPictures'), buttons = $('.buttons'), imgYS = loopPictures.find('img'), imgWidth = imgYS.css('width'), imgHeight = imgYS.css('height'), kick = buttons.find('span');console.log(imgWidth); console.log(imgHeight);
问题解答
回答1:你这是 获取style 样式 height , 你在CSS 里面没有设置 就肯定没有的, 你可以用document.getElementsByClassName('class')[0].offsetHeight 获取,或者直接用jquery $('.class').height()
相关文章:
1. windows误人子弟啊2. php传对应的id值为什么传不了啊有木有大神会的看我下方截图3. python - linux 下用wsgifunc 运行web.py该如何修改代码4. python - oslo_config5. 关于mysql联合查询一对多的显示结果问题6. 实现bing搜索工具urlAPI提交7. 冒昧问一下,我这php代码哪里出错了???8. mysql优化 - MySQL如何为配置表建立索引?9. MySQL主键冲突时的更新操作和替换操作在功能上有什么差别(如图)10. 数据库 - Mysql的存储过程真的是个坑!求助下面的存储过程哪里错啦,实在是找不到哪里的问题了。
