简体   繁体   English

jQuery替换/删除没有ID或标签的属性

[英]jQuery replace/remove attribute without id or tag

I am new to jquery, and I'm having trouble doing what I thought should be a very simple find and replace operation. 我是jquery新手,在执行我认为应该是非常简单的查找和替换操作的操作时遇到了麻烦。

I want to remove disabled attribute. 我想删除禁用的属性。 I already searching jquery remove sample, but always using id or tag. 我已经在搜索jquery删除示例,但始终使用id或tag。

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

I try this code but not working. 我尝试此代码,但无法正常工作。

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

Use a selector on the attribute and remove it when found. 在属性上使用选择器,找到后将其删除。 It is by the way NEVER a good idea to try to use regex/replace on HTML tags 顺便说一句,尝试在HTML标签上使用正则表达式/替换永远不是一个好主意

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM