我想更改整个 html 文档中 class="testingCase"
的所有属性名称。
例如改变:
<a class="testingCase" href="#" title="name of testing case">Blabla</a>
<a class="testingCase" href="#" title="name of another testing case">Bloo</a>
对此:
<a class="testingCase" href="#" newTitleName="name of testing case">Blabla</a>`
<a class="testingCase" href="#" newTitleName="name of another testing case">Bloo</a>`
我正在考虑查找和替换,但对于如此简单的事情来说,这似乎有很多代码。是否有用于此或简单方法的 jQuery 函数?
原文由 Ice 发布,翻译遵循 CC BY-SA 4.0 许可协议
在javascript中没有内置的方法/函数来“重命名”一个属性,但是你可以创建新的属性并删除其他的……
编辑:在使其仅选择
a
class=“testingCase” 的元素中添加