zoukankan      html  css  js  c++  java
  • 动态创建的文本框想要加上jQuery的datepicker功能变成日期选择控件该怎么办?

    通常页面输入控件想得到日期选择功能,借助jQuery是这样实现的:

    1.载入css和js

    <script src="jqueryui/jquery-ui.js" type="text/javascript"></script>
    <link rel="stylesheet" rev="stylesheet" href="jqueryui/jquery-ui.css" type="text/css" />

    2.对控件调用datepicker(),如

    $("#dateTxt").datepicker();

    但是如果输入框是动态创建的该怎么办呢?

    如下:

    var inputDate=document.createElement("input");
    inputDate.setAttribute("class","field size4");

    inputDate.setAttribute("onfocus","$(this).datepicker();");

    或是
    inputDate.setAttribute("onclick","$(this).datepicker();");

    就可以了。

  • 相关阅读:
    vue之v-on
    垂直居中下
    垂直居中上
    vue之v-for
    vue之v-if和v-show
    vue之v-model
    vue之v-bind
    数学---目录
    【数学】证明题
    【计算机网络】应用层
  • 原文地址:https://www.cnblogs.com/heyang78/p/7608874.html
Copyright © 2011-2022 走看看