3

我正在尝试禁用两个锚标记,但无法删除下划线。我也想去掉蓝色。这就是我所拥有的,它没有删除下划线。我已经尝试将文本装饰设置为nonenone !important

        $(document).ready(function ()
        {
            // See if doc upload View and Remove panel is displayed --> do they currently have a document uploaded 
            var isInline = $("#ctl00_contentMain_pnlAuthorizationForReleaseViewUploadDocument").css('display');

            // if so disable upload and electronic sig links
            if (isInline == "inline")
            {
                //Disable Upload Link after document is uploaded
                $("#ctl00_contentMain_btnUpload").attr('onclick', '').click(function (e) {
                    e.preventDefault();
                });
                $("#ctl00_contentMain_btnUpload").attr('href', '');
                $("#ctl00_contentMain_btnUpload").attr('text-decoration', 'none !important');

                //Disable Electronic Sign Link after document is uploaded
                $("#ctl00_contentMain_lnkESign").attr('onclick', '').click(function (e) {
                    e.preventDefault();
                });
                $("#ctl00_contentMain_lnkESign").attr('href', '');
                $("#ctl00_contentMain_lnkESign").attr('text-decoration', 'none !important');
            }

        });

这是aspx代码

<asp:LinkButton ID="lnkESign" 
                runat="server" 
                Text="sign"  
                TabIndex="1" 
                OnClick="lnkESign_Click">

<asp:LinkButton ID="lnkDownloadReleasefrm" runat="server" Text="Download"
                                        TabIndex="1"></asp:LinkButton>

Which renders this HTML

<a id="ctl00_contentMain_lnkESign" href="" tabindex="1" onclick="" text-decoration="none !important">sign</a>

<a href="" tabindex="2" id="ctl00_contentMain_btnUpload" onclick="" text-decoration="none !important">Upload </a>

编辑

这是我最终使用的代码

    $("#ctl00_contentMain_btnUpload").attr('href', '').css('text-decoration', 'none').css('color', 'black').attr('onclick', '').click(function (e) {
        e.preventDefault();
    });
4

3 回答 3

7

text-decoration不是属性..这是css中的规则。你应该像下面这样尝试,

$("#ctl00_contentMain_lnkESign").css('text-decoration', 'none');

注意:不需要,!important因为这将是一个内联样式。

于 2013-01-03T19:50:53.637 回答
2

而不是.attr(key, value)使用.css(key, value)

您将无法更改 :hover 、 :visited 等颜色,因为这些伪样式仅适用于样式表。将一个类添加到您的 css 文件中可能是有意义的.disabled,然后将该 css 类添加到链接中.addClass()

于 2013-01-03T19:51:58.950 回答
1

您可能还需要考虑在样式表中为禁用的锚定义一个类,该锚控制colortext-decoration使用 jquery 来切换该类,而不是使用内联样式。

CSS

/* Applied to all anchors for default enabled appearance */
.anchor
{
  ...
}

/* Applied to display a disabled anchor */
.anchor.disabled
{
  color: #ddd;
  text-decoration: none;
}

JavaScript

$("#ctl00_contentMain_lnkESign").toggleClass('disabled');
于 2013-01-03T20:03:48.290 回答