Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.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
Php 选择jquery的问题_Php_Javascript_Jquery_Selector - Fatal编程技术网

Php 选择jquery的问题

Php 选择jquery的问题,php,javascript,jquery,selector,Php,Javascript,Jquery,Selector,在我的代码中,我有一个循环,它会产生各种2小时的时间块。我发现从.clientSearchSectionButtonHiddentExtendedTime中获取文本非常困难。从.clientSearchSectionButtonHiddenExtStartTime中获取文本没有问题 PHP 尝试使用.find()而不是.next() 对于exmaple: endTime = $(this).parent().find(".clientSearchSectionButtonHiddenTextEn

在我的代码中,我有一个循环,它会产生各种2小时的时间块。我发现从.clientSearchSectionButtonHiddentExtendedTime中获取文本非常困难。从.clientSearchSectionButtonHiddenExtStartTime中获取文本没有问题

PHP

尝试使用.find()而不是.next()

对于exmaple:

endTime = $(this).parent().find(".clientSearchSectionButtonHiddenTextEndTime").text();
尝试使用.find()而不是.next()

对于exmaple:

endTime = $(this).parent().find(".clientSearchSectionButtonHiddenTextEndTime").text();

如果不需要查看,可以使用这样隐藏的输入

<input type="hidden" name="clientSearchSectionButtonHiddenTextStartTime[]" value="<?php echo $row['startTime']; ?>" />
<input type="hidden" name="clientSearchSectionButtonHiddenTextEndTime[]" value="<?php echo $row['endTime']; ?>" />
/*----SELECT TIME----*/ 
$(".clientSearchSectionButtonTextTime").live("click", function() {
   startTime = $(this).parent('groups').find(".clientSearchSectionButtonHiddenTextStartTime").text();
   endTime = $(this).parent('groups').find(".clientSearchSectionButtonHiddenTextEndTime").text();
   alert (endTime);
}))


我没有尝试过,但如果您不需要查看,应该可以使用这样隐藏的输入

<input type="hidden" name="clientSearchSectionButtonHiddenTextStartTime[]" value="<?php echo $row['startTime']; ?>" />
<input type="hidden" name="clientSearchSectionButtonHiddenTextEndTime[]" value="<?php echo $row['endTime']; ?>" />
/*----SELECT TIME----*/ 
$(".clientSearchSectionButtonTextTime").live("click", function() {
   startTime = $(this).parent('groups').find(".clientSearchSectionButtonHiddenTextStartTime").text();
   endTime = $(this).parent('groups').find(".clientSearchSectionButtonHiddenTextEndTime").text();
   alert (endTime);
}))

我没有尝试,但应该可以

足够肯定,
.next()
只选择下一个兄弟姐妹。若给定了选择器,那个么将测试单个同级以匹配它,否则结果为空

试试
.nextAll('.uncannyClassName')
,你就可以开始了

/*----SELECT TIME----*/ 
$(".clientSearchSectionButtonTextTime").live("click", function() {
    startTime = $(this).parent().nextAll(".clientSearchSectionButtonHiddenTextStartTime").text();
    endTime = $(this).parent().nextAll(".clientSearchSectionButtonHiddenTextEndTime").text();
    alert (endTime);
});
我还将它添加到
.clientSearchSectionButtonHiddenTextStartTime
中,以允许将来对DOM的可伸缩性(而不仅仅是通过选择下一个元素)。

当然,
.next()
只选择下一个同级。若给定了选择器,那个么将测试单个同级以匹配它,否则结果为空

试试
.nextAll('.uncannyClassName')
,你就可以开始了

/*----SELECT TIME----*/ 
$(".clientSearchSectionButtonTextTime").live("click", function() {
    startTime = $(this).parent().nextAll(".clientSearchSectionButtonHiddenTextStartTime").text();
    endTime = $(this).parent().nextAll(".clientSearchSectionButtonHiddenTextEndTime").text();
    alert (endTime);
});
我还将它添加到
.clientSearchSectionButtonHiddenExtStartTime
,以允许将来对DOM的可伸缩性(而不仅仅是通过选择下一个元素)。

echo'
“.$startTimeCorrected.”-“$endTimeCorrected.”
“.$row[“startTime”]”
“.$row[“endTime”]”
';
$(“.ClientSearchSectionButtonExtTime”).live(“单击”,函数(){
name=$(this.getAttribute(“name”);
startTime=$('.ClientSearchSectionButtonHiddenExtStartTime[name=“”+name+”);
});
我已经有一段时间没有编写自己的CSS选择器了,但是您应该能够理解这个想法。
在每个div/span上放置一个公共标识符,比在DOM中导航更容易。

echo'
“.$startTimeCorrected.”-“$endTimeCorrected.”
“.$row[“startTime”]”
“.$row[“endTime”]”
';
$(“.ClientSearchSectionButtonExtTime”).live(“单击”,函数(){
name=$(this.getAttribute(“name”);
startTime=$('.ClientSearchSectionButtonHiddenExtStartTime[name=“”+name+”);
});
我已经有一段时间没有编写自己的CSS选择器了,但是您应该能够理解这个想法。
在每个div/span上放置一个公共标识符,比尝试在DOM中导航更容易。

如果
next()
closest()
解决方案不起作用,则需要调试代码。首先执行此操作,看看它是否有效:

/*----SELECT TIME----*/ 
$(".clientSearchSectionButtonTextTime").live("click", function() {
    alert ($(this).parent().next(".clientSearchSectionButtonHiddenTextStartTime").text());
    //startTime = $(this).parent().next(".clientSearchSectionButtonHiddenTextStartTime").text();
    //endTime = $(this).parent().next(".clientSearchSectionButtonHiddenTextEndTime").text();
});
如果
next()
closest()
解决方案不起作用,则需要调试代码。首先执行此操作,看看它是否有效:

/*----SELECT TIME----*/ 
$(".clientSearchSectionButtonTextTime").live("click", function() {
    alert ($(this).parent().next(".clientSearchSectionButtonHiddenTextStartTime").text());
    //startTime = $(this).parent().next(".clientSearchSectionButtonHiddenTextStartTime").text();
    //endTime = $(this).parent().next(".clientSearchSectionButtonHiddenTextEndTime").text();
});


非常长的类名,考虑缩短它们!您调试过吗?**请在单击事件中发出警报!是的,这是一个超级复杂的设计,从整个网站的所有内容都放在一个页面上…没有长的类名,信息会进入错误的位置…我通常不会使用它们,但在这种情况下,这是唯一的方式我只是感到沮丧,我无法抓到文本…我还尝试使用startTime并添加2小时,但当我尝试这样做时,这也带来了它自己的问题。另外,如果我愿意的话,我希望可以自由地将时间块设置为3小时以上。我已经调试了数小时,JSFIDLE说一切正常,我还添加了其他可以正常工作的警报。警报(开始时间)工作,这是关于
警报(结束时间)的最重要内容非常长的类名,考虑缩短它们吧!您调试过吗?**请在单击事件中发出警报!是的,这是一个超级复杂的设计,从整个网站的所有内容都放在一个页面上…没有长的类名,信息会进入错误的位置…我通常不会使用它们,但在这种情况下,这是唯一的方式我只是感到沮丧,我无法抓到文本…我还尝试使用startTime并添加2小时,但当我尝试这样做时,这也带来了它自己的问题。另外,如果我愿意的话,我希望可以自由地将时间块设置为3小时以上。我已经调试了数小时,JSFIDLE说一切正常,我还添加了其他可以正常工作的警报。警报(开始时间)工作,这是关于
警报(结束时间)的最重要内容?我得到一个空白警报,与.next()相同当我在firebug中探索时,文本肯定在那里我得到一个空白警报,与.next()相同当我在firebug中探索时,文本肯定在其中除此之外。如果您使用HTML5(我强烈推荐),您可以使用
数据my data chunk
属性将“隐藏”数据存储到任何元素中,并使用
$(this)检索它们。数据('my-data-chunk')
。我赌这一个,这就是我的答案是肯定的!这很有效,非常感谢你向我解释。除此之外,我相信每个人都会觉得它很有用。如果您使用HTML5(我强烈推荐),您可以使用
数据my data chunk
属性将“隐藏”数据存储到任何元素中,并使用
$(this)检索它们。数据('my-data-chunk')
。我赌这一个,这就是我的答案是肯定的!这很有效,非常感谢你向我解释。我相信每个人都会觉得这很有帮助,所以我可能会在一分钟内开始重新安排事情,以符合您的第一个建议,但第二个建议仍然会返回一个空白警报。奇怪的是,每个人提出的所有解决方案都应该有效,包括我最初的解决方案……我们一定找错了方向