简体   繁体   中英

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? Is a JavaScript error being thrown before .datepicker() is called?

Both ok.

Try to use web develop tools and step into the code to find out the errors.

try using following selector:

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

Working example is here

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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