我怎么能选择一个表标题有相同的类名,而不是任何其他唯一的属性在web驱动程序
How can I select a table heading which have same class name and not any other unique attribute in web driver
<th id="desc" class="sort" data="aWQ=">S.No</th>
<th class="table_head" data="bmFtZQ==">Customer</th>
<th class="table_head" data="c3R5bGVfbm8=">Style#</th>
<th class="table_head" data="c3R5bGVfZGVzYw==">Style Description</th>
<th class="table_head" data="ZmFicmljX2Rlc2M=">Fabric Description</th>
<th class="table_head" data="YXBwcm92ZWQ=">Status</th>
<th>Action </th>
able代码为所有列声明相同的类名,ID &CLASS仅在用户选择要过滤的列时分配。在这种情况下,我如何选择所有的列
使用jQuery可以这样做:
$('th').eq(1) // the "customer" element
$('th').eq(4) // the "fabric description" element
在普通JS中,就像这样简单:
document.querySelectorAll('th')[1] // the "customer" element
document.querySelectorAll('th')[4] // the "fabric description" element
有了这个,您可以很容易地选择第n个表列,但是您必须事先知道该列的索引。
相关文章:
- 将不同上传的文件显示为缩略图或任何其他方式
- 地理定位在Jsfidle中工作,但不在任何其他JS编辑器中
- Mocking console.log()/MOCHA测试框架中的任何其他函数
- 当单击任何其他工具提示时,无法打开uib工具提示
- get_browser降低页面加载速度,任何其他选择
- 检测Firebug(或任何其他Web调试器)何时用于调试
- 节点.js“已调用回调”.但是没有任何其他回调
- 如何将timbre.js缓冲区导出为.wav或任何其他音频文件格式
- 如何使用cordova在Whatsapp/Facebook/Instagram和任何其他社交媒体上分享图片
- 可以Flot(或任何其他JQuery图表库)绘制公式
- 如何在使用任何其他数据库的同时,用javascript获取所有mongo数据库的列表
- 我在哪里可以获得印度的.geojson文件,而不是每个州/地区的单独文件或任何其他区别
- Gulp-Concat文件的顺序然后是任何其他的js文件
- 下划线where with or condition(下划线、lodash或任何其他解决方案)
- Javascript可以在Safari上运行,但不能在任何其他浏览器上运行
- Regex-仅当字符串包含任何其他字符时才允许使用某些字符
- 在这种javascript情况下,除了eval之外的任何其他选项
- 如何在没有jQuery或任何其他库的情况下捕获CTRL-S
- 未定义GM_openInTab(或任何其他GM_函数)
- 退出弹出重定向,但仅在退出时执行,而不是在单击页面上的任何其他 html 重定向按钮时执行