前言:有的日期控件可以输入日期,有的不可以手动输入,对于不可以输入的日历控件,需要先用 js 去掉 readonly 属性,然后直接输入日期文本内容

1、日历控件,以12306为例

13、 js处理日历控件(去掉 readonly )

 

 2、手动去掉readonly,双击readonly,删除掉,出发日期中就可以手动输入内容了,如下图:

13、 js处理日历控件(去掉 readonly )

 

 3、js去掉readonly、再输入日期

用 js 去掉元素属性基本思路:先定位到元素,然后用 removeAttribute("readonly")方法删除属性

出发日元素 id 为:train_date,对应 js 代码为: 'document.getElementById("train_date").removeAttribute("readonly");'

13、 js处理日历控件(去掉 readonly )

 

 

相关文章:

  • 2022-01-22
  • 2021-07-11
  • 2021-12-05
  • 2021-12-05
  • 2021-06-24
  • 2021-12-22
猜你喜欢
  • 2021-05-25
  • 2021-06-12
  • 2022-12-23
  • 2022-12-23
  • 2021-07-26
  • 2021-10-19
相关资源
相似解决方案