更多的是出于好奇而不是解决方案的实际需要。我有一个脚本,其中我称之为n-child,偶然我把孩子的部分留下来并且它起作用了。但是,我抓住了这个错误并修复了它,但是脚本停止了工作,所以我再次取出了“child”并且脚本再次运行了。这是在jquery btw。任何人都知道如何发生这种情况?
if($('#user1').children().children('tr:nth-child('+y+')').children('.user2:nth('+x+')').children().hasClass('leftborder')){
作品
if($('#user1').children().children('tr:nth-child('+y+')').children('.user2:nth-child('+x+')').children().hasClass('leftborder')){
不起作用
<table id="user1">
<tr><!--row 1-->
<td class="user1">
<div class="up arrow"><div class="upbutton button"></div></div>
<div class="down arrow"><div class="downbutton button"></div></div>
<div class="left arrow"><div class="leftbutton button"></div></div>
<div class="right arrow"><div class="rightbutton button"></div></div>
</td>
<td class="user2">
<div class="up arrow"><div class="upbutton button"></div></div>
<div class="down arrow"><div class="downbutton button"></div></div>
<div class="left arrow"><div class="leftbutton button"></div></div>
<div class="right arrow"><div class="rightbutton button"></div></div>
</td>
是一般的想法
并澄清,该表在我的实际文档中已关闭,if语句也已完成,据我所知,这与该问题并不完全相关。
有人指出,没有任何类别的左边界,这是在前面的行
中添加的$('.leftbutton').click(function(){
$(this).parent().parent().children('.left').toggleClass('leftborder');
请求x和y的值
var rows=$('#user1').children().children().size();
for(y=1;y<=rows;y++){
var cols=$('#user1').children().children('tr:nth- child('+y+')').children('.user1').size();
for(x=1;x<=cols;x++){