如何添加当前的datetimepicker并添加第二个?

时间:2016-07-21 10:18:18

标签: javascript jquery datetime datetimepicker

演示和完整代码如下:http://fiddle.jshell.net/TC6Gr/436/

我的javascript代码是这样的:

$('#time-start').datetimepicker({
    format: 'mm/dd/yyyy hh:ii',
    autoclose: true,
    pickerPosition: "bottom-left",
    maxView: 3,
    minuteStep: 1
})

我想要执行代码,它会查看当前的日期时间。我也想看第二个。所以,第二也看了。第二个也选中了。我在谷歌搜索回复,但我没有找到它。我还是很困惑

解决我问题的任何解决方案?

3 个答案:

答案 0 :(得分:1)

试试这个:

Fiddle

HTML:

 <div class="col-sm-6 start-date">
   <div class='input-group date' id="time-end">
      <input type='text' id="time-start" class="form-control" placeholder="End Time" >
      <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
   </div>
</div>

脚本:

Number.prototype.padLeft = function(base,chr){
   var  len = (String(base || 10).length - String(this).length)+1;
   return len > 0? new Array(len).join(chr || '0')+this : this;
}



    var d = new Date,
        dformat = [ (d.getMonth()+1).padLeft(),
                    d.getDate().padLeft(),
                    d.getFullYear()].join('/')+
                    ' ' +
                  [ d.getHours().padLeft(),
                    d.getMinutes().padLeft(),
                    d.getSeconds().padLeft()].join(':');
     $('#time-start').val(dformat);

$('#time-start').datetimepicker({
     format: 'mm/dd/yyyy hh:ii:ss',
    autoclose: true,
    pickerPosition: "bottom-left",
    maxView: 3,
    minuteStep: 1
})

答案 1 :(得分:0)

试试这个

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

url = 'http://passport2.chaoxing.com/login?fid=1479&refer=http://i.mooc.chaoxing.com'

driver = webdriver.Firefox()
driver.get(url)

wait = WebDriverWait(driver, 10)

span = wait.until(EC.visibility_of_element_located((By.ID, "nameNoteId")))
span.click()

unameId = wait.until(EC.visibility_of_element_located((By.ID, "unameId")))
unameId.send_keys('test')

passwordId = wait.until(EC.visibility_of_element_located((By.ID, "passwordId")))
passwordId.send_keys('CNM')

答案 2 :(得分:0)

只需为idtime time-end添加datetimepicker的第二个输入,并为其初始化datetimepicker:

演示:http://fiddle.jshell.net/wxoud40L/

<div class="col-sm-6 start-date">
   <div class='input-group date' id="time-end">
      <input type='text' class="form-control" placeholder="End Time" readonly>
      <span class="input-group-addon"><span class="glyphicon lyphicon-calendar"></span></span>
   </div>
</div>

Jquery的

$('#time-end').datetimepicker({
    format: 'mm/dd/yyyy hh:ii:ss',
    timeFormat: 'hh:ii:ss',
    autoclose: true,
    pickerPosition: "bottom-left",
    maxView: 3,
    minuteStep: 1
});