gpt4 book ai didi

javascript - 当复选框选中时如何单击不同 div 的标签?

转载 作者:行者123 更新时间:2023-12-03 00:08:26 24 4
gpt4 key购买 nike

当复选框被选中时,

我想触发点击同一tr标签中具有下载功能的标签(按顺序)点击[开始下载]按钮。

它们在不同的<< td >>标签中,彼此在同一个<< tr >>标签中

如何按顺序触发点击?

我是否需要使用for语句按复选框顺序单击不同div中的元素?

<tr>
<td id="10Mb.dat"><input type="checkbox" data-url="https://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73751/world.topo.bathy.200407.3x21600x10800.jpg" />File10MB
</td>
<td class="test"><a class="checkBtn checkBtn1" id="checkBtn1" onclick="download_file(event, '10Mb.dat')">download</a></td>
</tr>
<tr>
<td id="100mb.bin"><input type="checkbox" data-url="http://speedtest-ny.turnkeyinternet.net/100mb.bin" />File100MB
</td>
<td class="test"><a class="checkBtn checkBtn2" id="checkBtn2" onclick="download_file(event, '100mb.bin')">download</a></td>
</tr>
<button class="btn btn-primary compress">download start</button>

最佳答案

为您的复选框提供一个 css 类。

$('.checkboxclass').click(function(){
$(this).closest('td').parents('tr').find('.checkBtn').click();
}

要使用按钮进行检查,请循环访问表中选中的复选框,

$("table.test 
input:checkbox:checked").parents('tr').find("input[name$='.checkBtn']")
.each(function(){
download(link); //write the code to download file
}

关于javascript - 当复选框选中时如何单击不同 div 的标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54858715/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com