Get HTML Anchor Link text on Click using jQuery

suhaas121
 
on Aug 20, 2021 10:55 PM
Sample_321892.zip
1403 Views

Hi 

how to get html link text on click ? Please help

<a href="sample.aspx" >text</a>

I want to get name of  <a> tag on click.

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Aug 21, 2021 05:36 AM
on Feb 08, 2022 09:40 AM

Hi suhaas121,

Refer below code.

HTML

<a href="#">ASPSnippets</a>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        $('a').click(function () {
            alert($(this).html());
        });
    });
</script>

Demo