nowisthebest 发表于 2021-8-22 02:17:29

新手求助:无id的标签如何模拟点击

本帖最后由 nowisthebest 于 2021-8-22 02:26 编辑

请问老师们,无id的标签怎么模拟点击,元素如下图



<div style="" class="datagrid-cell datagrid-cell-c1--"><a href="javascript:void(0)" style="padding-left:10px;text-decoration:none;color:blue;padding-right:20px;"><i class="iconfont"></i></a><a href="javascript:void(0)" style="text-decoration:none;margin-left:20px;color:blue;"><i class="iconfont"></i>新增分单</a></div>


铅笔是一个超链接,新增分单是一个超链接。非常感谢!

李恒道 发表于 2021-8-22 02:17:30

https://bbs.tampermonkey.net.cn/thread-835-1-1.html

涛之雨 发表于 2021-8-22 07:45:32

方法很多

* 通过`.datagrid-cell.datagrid-cell-c1--`这个class啊
* 通过`table`的`id`遍历节点啊
* 直接js执行那个onclick事件

都可以。。。

主要看情况估计要遍历,而且每个遍历的内容估计还不少。。。

Ne-21 发表于 2021-8-22 09:07:43

没有id可以css呀,选择器不是有好几个呢么

nowisthebest 发表于 2021-8-22 11:47:10

Ne-21 发表于 2021-8-22 09:07
没有id可以css呀,选择器不是有好几个呢么

不懂CSS啊,谢谢,我研究下

nowisthebest 发表于 2021-8-22 12:20:09

涛之雨 发表于 2021-8-22 07:45
方法很多

* 通过`.datagrid-cell.datagrid-cell-c1--`这个class啊


谢谢,我再学习下

李恒道 发表于 2021-8-22 13:30:44

可以获取table tr td这么一层一层的

nowisthebest 发表于 2021-8-22 16:16:03

李恒道 发表于 2021-8-22 13:30
可以获取table tr td这么一层一层的

好的,谢谢老师,我学习下!
页: [1]
查看完整版本: 新手求助:无id的标签如何模拟点击