未捕获的TypeError:无法读取未定义的属性"left" [英] Uncaught TypeError: Cannot read property 'left' of undefined

查看:201
本文介绍了未捕获的TypeError:无法读取未定义的属性"left"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当出现此错误时,我似乎无法在隐藏字段上显示jQuery UI的日期选择器:

I'm can't seem to show a datepicker from jQuery UI on a hidden field as i get this error:

Uncaught TypeError: Cannot read property 'left' of undefined

当我使用常规文本字段时,我似乎没有问题.我同时出现jQuery UI 1.9.01.9.2(jQuery is 1.8.3

When I use a regular text field, i don't seem to have a problem. I get this error with both jQuery UI 1.9.0 and 1.9.2, the version of jQuery is 1.8.3

html

<table>
    <tr>
        <td> 
            <small class="date_target">until <span>Dec. 31, 2013</span></small>
            <input type="hidden" class="end_date" />
        </td>
    </tr>
</table>

JS

$(".end_date").datepicker({
    dateFormat: 'yyyy-mm-yy',
    yearRange: '-00:+01'
});

$('.date_target').click(function () {
    $(this).next().datepicker('show');
});

我也在此 jsfiddle 上提供了一个(不是)工作示例

I provided a (not) working example on this jsfiddle too

推荐答案

这是因为输入字段对浏览器不可见(因为它是隐藏的).

It's because the input field is not visible to the browser (because it's hidden).

尝试一下:

<input type="text" style="height: 0px; width:0px; border: 0px;" class="end_date" />

,你很好.当然,您可以将额外的样式属性添加到CSS类"end_date". "display:none"无济于事,因为此字段再次完全不可见.

and you are fine. Of course, you can add the extra style attributes to the CSS class "end_date". A "display:none" will not help, because then the field is fully invisible again.

JS小提琴中的示例.

这篇关于未捕获的TypeError:无法读取未定义的属性"left"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆