jQuery替换/删除没有id或标记的属性

jQuery replace/remove attribute without id or tag

本文关键字:属性 id 替换 删除 jQuery      更新时间:2023-09-26

我是jquery的新手,在执行我认为应该非常简单的查找和替换操作时遇到了问题。

我想删除禁用的属性。我已经在搜索jqueryremove-sample,但总是使用id或tag。

    <td><a href="xx.html" disabled onclick="preparexForm(this,'xx')" class="btn">ok</a> </td>

我尝试了这个代码,但不起作用。

$("body *").replaceText( /disabled|disable/gi, "enable" );

在属性上使用选择器,并在找到时将其移除。顺便说一下,尝试在HTML标签上使用regex/replace从来都不是一个好主意

$("a[disabled]").each(function() {
  $(this).removeAttr("disabled");
});