javascript - About DOM elements internal indentifier
问题描述
I'd like to identify univocally some DOM elements (specifically, the <li>
elements of an <ul>
list). First, I thought about using the id
or data-
attributes, but I declined the option because these attributes can be changed easily using the developer tools.
Is there any internal id that I could use for this purpose?
Thanks!
解决方案
There is no internal ids for elements. There is no way to really set an id on an element that can not be changed.
Only thing you really can do is hold references to elements in an array/object/variables, but even a person could set a break point in the code and alter that.
So in the end, there is really no way to identify an element and not have a person muck in developer tools and change it.
推荐阅读
- wagtail - 无法让联合查询在 Wagtail 中的不同模型中工作
- sql-server - 如何修复 SSIS 中缺少的 SQL 连接管理器
- r - 通过数据帧循环函数,区分,然后在原始数据帧中按列组合
- php - 遍历 JSON 请求的多个页面(Guzzle、Laravel、PHP)
- blazor - 当我在表单中选择另一个文本框时,羽毛笔编辑器的内容被清除
- python - 我的代码返回“命令 '['python3']' 2 秒后超时”
- c# - 就地更新 PDF 图像
- javascript - React Native:获取函数发送空主体
- neo4j - 从 neo4j 中的 2 个 csv 文件导入数据
- python - 在我的 Django 项目中提取了错误的日期时间