Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.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 单击链接后增加ID的值_Javascript_Jquery_Datepicker - Fatal编程技术网

Javascript 单击链接后增加ID的值

Javascript 单击链接后增加ID的值,javascript,jquery,datepicker,Javascript,Jquery,Datepicker,我正在使用一个日期选择器“开始日期”和“结束日期”,在我的php页面中,我也在使用“添加更多字段”,我想,当我单击“添加更多”时,它也应该增加日期id,下面的代码将给你更好的想法 <script> if (top.location != location) { top.location.href = document.location.href ; } $(function(){ window.prettyPrint && prettyPrint(); if(to

我正在使用一个日期选择器“开始日期”和“结束日期”,在我的php页面中,我也在使用“添加更多字段”,我想,当我单击“添加更多”时,它也应该增加日期id,下面的代码将给你更好的想法

<script>
if (top.location != location) {
top.location.href = document.location.href ;
}
$(function(){
window.prettyPrint && prettyPrint();

if(top.location!=位置){
top.location.href=document.location.href;
}
$(函数(){
window.prettyPrint&&prettyPrint();
//禁用日期 var nowTemp=新日期(); var now=新日期(nowTemp.getFullYear(),nowTemp.getMonth(),nowTemp.getDate(),0,0,0)

var值=1;
值++;
var checkin=$('#dpd1').html(值).datepicker({
onRender:函数(日期){
返回日期.valueOf()checkout.date.valueOf()){
var newDate=新日期(ev.Date)
newDate.setDate(newDate.getDate()+1);
checkout.setValue(newDate);
}
checkin.hide();
$('#dpd2').html(值)[0].focus();
}).数据(“日期选择器”);
var checkout=$('#dpd2').html(值).datepicker({
onRender:函数(日期){

return date.valueOf()如果我正确理解了您的问题,那么您实际上并没有试图更改特定元素的ID,而是尝试递增选择器以使其选择适当的元素。是否正确

如果是这种情况,您可以在选择器中使用变量。而不是执行以下操作:

$("#dpd2").html(value).focus(); 
你可以这样做:

var currentDatePickerID = 0; 
并在每次单击按钮时将其递增,然后您的选择器将如下所示:

$("#dpd" + currentDatePickerID).html(value).focus(); 

这样,您的选择器是动态的。

这里是解决方案..我在脚本中实现了

var counterTouring = 1;
$('.add-touring').click(function(event){
event.preventDefault();
counterTouring++;

var checkin = $('#dpd1' + counterTouring).html(value).datepicker({ 
//---- 
});

谢谢大家!

我不知道Jscript,我需要帮助来解决这个问题,请帮助…..我将感谢你们所有人。等一秒钟,看看它,然后会有所帮助。Lorrae你想在你点击“更多…”时增加DateTimePicker的当前位置,还是每次都添加一行信息?我对你的问题感到困惑。
$("#dpd" + currentDatePickerID).html(value).focus(); 
var counterTouring = 1;
$('.add-touring').click(function(event){
event.preventDefault();
counterTouring++;

var checkin = $('#dpd1' + counterTouring).html(value).datepicker({ 
//---- 
});