3

2つのアンカータグを無効にしようとしていますが、アンダースコアを削除できません。青い色も消したいのですが。これが私が持っているもので、下線が削除されていません。noneとに設定されたテキスト装飾を試しましたnone !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 などの色を変更することはできません。これらの疑似スタイルはスタイルシートでのみ機能するためです。.disabled次のようにcssファイルにクラスを追加し、そのcssクラスをリンクに追加するのは理にかなっているかもしれません.addClass()

于 2013-01-03T19:51:58.950 に答える
1

また、インライン スタイルを使用する代わりに、 とcolorの両方を制御する無効なアンカーのクラスをスタイルシートで定義し、jquery を使用してそのクラスを切り替えることを検討することもできます。text-decoration

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 に答える