Hide Anchor link from browser status bar on Mouseover in jQuery

Last Reply 3 months ago By pandeyism

Posted 3 months ago

 

I want  "hide link mouseover" in below soln:

https://www.aspforums.net/Threads/142386/Show-only-the-first-and-last-four-digit-of-a-number-using-JavaScript/

How can I do that?

Please anybody help me.

You are viewing reply posted by: pandeyism 3 months ago.
Posted 3 months ago Modified on 3 months ago

Hi Alauddin,

Please refer below sample.

HTML

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
    window.onload = function () {
        var table = document.getElementsByTagName("table");
        var trs = table[0].getElementsByTagName('tr');
        for (var i = 0; i < trs.length; i++) {
            var tds = trs[i].getElementsByTagName('td');
            var cardno = tds[1].innerText;
            if (cardno.length > 5) {
                var firstFour = cardno.substr(0, 4);
                var lastFour = cardno.substr(cardno.length - 4, cardno.length);
                var middle = cardno.substr(4, cardno.length - 8).replace(/[0-9]/g, "*");
                var newLink = document.createElement("a");
                newLink.setAttribute("Class", "link1");
                newLink.setAttribute("href", "https://www.Test.com/" + cardno);
                text = document.createTextNode(firstFour + middle + lastFour);
                newLink.appendChild(text);
                tds[1].appendChild(newLink);
            }
        }
    }
    $(document).on('mouseover', "a[Class='link1']", function (e) {
        $(this).attr('style', 'text-decoration:none');
        $(this).attr("href", "javascript:;");
        $(this).bind('click', false);
    });
    $(document).on('mouseout', "a[Class='link1']", function (e) {
        $(this).removeAttr('style');
        $(this).unbind('click', false);
    });
</script>
<div>
    <asp:Label ID="lblTable" runat="server"></asp:Label>
</div>

Namespaces

C#

using System.Text;
using System.Data;

Code

C#

protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("<table id='01717458720_CardList'>");
        sb.Append("<tr>");
        sb.Append("<td id='product_type'>CREDIT CARD</td>");
        sb.Append("<td id='card_no' abbr='*'>1111234567123456</td>");
        sb.Append("<td id='card_status'>INACTIVE</td>");
        sb.Append("<td id='acct_no'>N/A</td>");
        sb.Append("<td id='name'>Mr. X</td>");
        sb.Append("</tr><tr>");
        sb.Append("<td id='product_type'>DEBIT CARD</td>");
        sb.Append("<td id='card_no'>0000000000000000</td>");
        sb.Append("<td id='card_status'>ACTIVE</td>");
        sb.Append("<td id='acct_no'>55555555555</td>");
        sb.Append("<td id='name'>Mrs. Y</td>");
        sb.Append("</tr></table>");
        lblTable.Text = sb.ToString();
    }
}

Screenshot