简体   繁体   English

jQuery datepicker无法在给定类中的元素上工作

[英]Jquery datepicker not working on elements inside class given

If i use this then its working. 如果我使用它,那么它的工作。

<td ><div> Timestamp: </div><input type="text" value="" class="datepicker"/></td>
$( ".datepicker" ).datepicker();

This above code is working but this is not working 上面的代码有效,但是无效

<td  class="datepicker" ><div> Timestamp: </div><input type="text" value=""/></td>
    $( ".datepicker input" ).datepicker();

Those are both correct. 那些都是正确的。 Do you have some malformed HTML elsewhere on the page? 您在页面其他位置是否有格式错误的HTML? Is a JavaScript error being thrown before .datepicker() is called? 是否在调用.datepicker()之前引发JavaScript错误?

Both ok. 都可以

Try to use web develop tools and step into the code to find out the errors. 尝试使用Web开发工具并进入代码以找出错误。

try using following selector: 尝试使用以下选择器:

$("td.datepicker input:text").datepicker();

Working example is here 工作示例在这里

我认为您需要使用子选择器>

 $(".datepicker > input").datepicker();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM