Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/460.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将函数值切换到当前日期而不是精确日期_Javascript_Jquery_Sharepoint - Fatal编程技术网

Javascript 将函数值切换到当前日期而不是精确日期

Javascript 将函数值切换到当前日期而不是精确日期,javascript,jquery,sharepoint,Javascript,Jquery,Sharepoint,我将如何修改下面的函数以指定当前日期而不是2013年11月4日的值 <script type="text/javascript"> $('#FormsPageID table tr:nth-child(12) td:nth-child(2) div span span input') .on('focus', function(){ var $this = $(this); if($this.val() == '4/11/2013'){

我将如何修改下面的函数以指定当前日期而不是2013年11月4日的值

<script type="text/javascript">
$('#FormsPageID table tr:nth-child(12) td:nth-child(2) div span span input')
  .on('focus', function(){
      var $this = $(this);
      if($this.val() == '4/11/2013'){
          $this.val('');
      }
  })
  .on('blur', function(){
      var $this = $(this);
      if($this.val() == ''){
          $this.val('4/11/2013');
      }
  });
</script>

$(“#FormsPageID表tr:n子(12)td:n子(2)div span input')
.on('focus',function(){
var$this=$(this);
如果($this.val()=“4/11/2013”){
$this.val(“”);
}
})
.on('blur',function(){
var$this=$(this);
如果($this.val()=''){
$this.val('4/11/2013');
}
});
这会有用的

var date = new Date();
var strDate = (date.getMonth() + 1) + "/" + date.getDate() + "/" +date.getFullYear()

基于Parthik的答案,您可以将其作为一个函数,在.val()中调用它

在代码中,更改:

$this.val('4/11/2013');


单击此按钮:只是为了确定,我应该将此函数放在现有代码中的什么位置?在
.on
函数中的if语句中。
$this.val('4/11/2013');
$this.val(getCurrentDate());