所以,我有一个标签,看起来像:<a id="createBtn" class="btn" title="" type="button"><b>+</b>Create New</a>有时,我们希望它处于活动状态,有时则不是。我尝试了多种禁用它的方法,添加了禁用的类,添加了禁用的属性,尝试删除type属性(据我所知您无法做到),将其绑定到防止默认行为的函数,以及使用jQuery的,但似乎没有任何效果。我想知道可以禁用此标记的哪些js或jquery东西。它像被禁用一样变灰,但它仍然具有与之相关的动作,这是一个支柱这是我尝试过的一些方法,而不是全部方法: this.$('#createBtn').addClass('disabled'); this.$('#createBtn').attr('type', 'button'); this.$('#createBtn').bind('click', false); } else { this.$('#createBtn').removeAttr('type'); this.$('#createBtn').removeClass('disabled');#createBtn与事件相关联,该事件更新了在此主干视图的initialize方法中创建的UI。"click #createBtn": "renderNewTemplate", (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 这就是我禁用anchor标记(<a>)的方法:通过删除标签的href属性并减小其opacity来禁用该标签,从而获得更多效果:$(document).ready(function(){ $("#createBtn").click(function () { $(this).fadeTo("fast", .5).removeAttr("href"); });});并启用锚点:$(document).ready(function(){ $("#createBtn").click(function () { $(this).fadeIn("fast").attr("href", "original href here"); });});原始答案可以在这里找到-我只是在回收它,因为我在所有需要禁用锚标签的项目中都使用了它How to enable or disable an anchor using jQuery? (adsbygoogle = window.adsbygoogle || []).push({});
09-13 09:37