Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7992749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:39:31+00:00 2026-06-04T13:39:31+00:00

I need to capture the text between <a> and </a> tags and cause a

  • 0

I need to capture the text between <a> and </a> tags and cause a pop up message.I tried to do this as follows.However,what makes it difficult is that I cannot give id’s to the links since the links are dynamically generated.So I tried to give them a class and used jquery to select the element.

Then ,I am not sure how the currently clicked element can be selected using jquery.

Suppose,the links generated are as follows

<a href="#" class="mylinkclass"> first link </a> <br>
<a href="#" class="mylinkclass"> second link </a> <br>
<a href="#" class="mylinkclass"> third link </a> <br>
<a href="#" class="mylinkclass"> fourth link </a> <br>

In javascript, I am not sure how the currently clicked element can be selected using jquery. I know that $('.mylinkclass') would return an array of the above 4 links.How can I write the selector code?

$(document).ready(function(){
   $('.mylinkclass').click(function(){getLinkText();});
}

function getLinkText(){
    alert($(this).text());
    return false;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:39:33+00:00Added an answer on June 4, 2026 at 1:39 pm

    Change this…

     $('.mylinkclass').click(function(){getLinkText();});
    

    to this…

     $('.mylinkclass').click(getLinkText);
    

    So that you’re assigning the function directly as the handler. That way its this value will be a reference to the element clicked.


    If there was other work to be done before calling getLinkText, you could either pass the element by passing this as an argument…

     $('.mylinkclass').click(function(){
         // do other work
         getLinkText(this);
     });
    
    function getLinkText(el){
    
        alert($(el).text());
        return false;
    }
    

    Or by using .call or .apply to make this in the function have the same value…

     $('.mylinkclass').click(function(){
        // do other work
        getLinkText.apply(this, arguments);
     });
    
    function getLinkText(){
    
        alert($(this).text());
        return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this little code to capture text between brackets: $string = '[title=my title]
I'm retrieving raw text (includes header, and message) from a POP server. I need
$('input').change(function(){ alert($(this).val()); }); $('input').val(1); This dont work. I need capture the change input with
I need to make regex which will capture the following: Fixed unicode text: <br>
In my application, I need to add this functionality that there should be an
I'm trying to capture the text Capture This in $string below. $string = </th><td>Capture
This is my example script: $html = <<<HTML <div class=main> <div class=text> Capture this
How do I capture the text from the web page? Do I need to
I have a text file that contains very long lines. I need one piece
I need to build the ability to capture text from a window, like how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.