繁体   English   中英

jQuery日期选择器不适用于母版页

[英]jquery date picker not working with master page

jQuery datepicker无法使用母版页。 添加母版页ID后, datepicker不起作用。

请找到下面的代码以获取更多信息。

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
   <title>jQuery UI Datepicker - Default functionality</title>
   <link rel="stylesheet" ref="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
   <script src="//code.jquery.com/jquery-1.10.2.js"></script>
   <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
   <link rel="stylesheet" href="/resources/demos/style.css">
   <script>
      $(function () {
         $("#datepicker").datepicker();
      });
   </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
   <p>Date: <input type="text" id="datepicker"></p>
</asp:Content>

您需要添加属性ClientIDMode="Static来保存id

我建议改用class但不要覆盖服务器生成的ID。

喜欢:

<input type="text" id="datepicker" class="datepicker" />

然后:

$(function () {
   $(".datepicker").datepicker();
});

暂无
暂无

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

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