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 600797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:38:42+00:00 2026-05-13T16:38:42+00:00

I came across a strange problem with html anchor tags. I have an anchor

  • 0

I came across a strange problem with html anchor tags. I have an anchor tag on the html page and on clicking the ‘a’ tag it is supposed to give me an alert message. It is working well. But, If I append a new ‘a’ tag using jquery to the html page and on click of that appended ‘a’ tag is not working. i was able to give href, target blah blah blah to the appending ‘a’ tag but.. onlick function is not working. Any thoughts ???

Thanks in advance.

  • 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-05-13T16:38:42+00:00Added an answer on May 13, 2026 at 4:38 pm

    In jQuery, you typically use the .click() function on a selector to set the click handler. Note that if multiple items match the selector, multiple items will have the click handler installed.

    Here’s a trivial code snippet that should do what you want:

    <html>
        <head>
            <script type="text/javascript" src="jquery.js"></script>
        </head>
        <body>
            <script type="text/javascript">
    
            function addLink(label, msg) {
                /* Create link element.
                   The href="#" makes the link act like a link
                   (be highlighted, selectable, etc.).
                   The onClick="return false;" keeps the link from
                   scrolling the browser to the top of the page.
                   The onClick is not interfered with by jQuery's
                   .click() . */
                var link = $('<a href="#" onClick="return false;">' + label + '</a>');
    
                /* Install click handler. */
                function clicked_handler() {
                    alert(msg);
                }
                link.click(clicked_handler);
    
                /* Add the link to the body. */
                $('body').append(link);
            }
    
            addLink('Link 1', 'You clicked link 1');
            $('body').append('<br/>');
            addLink('Link 2', 'You clicked link 2');
    
            </script>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across a strange problem today. I created a subclass of UIView and
Today, I came across quite strange problem. I needed to calculate string length of
I came across a rather strange problem with linq-to-sql. In the following example, var
Came across something strange while migrating to my new server. I have a script
I have just started python and came across something kind of strange. The following
I came across a strange behaviour when doing some regular expressions in JavaScript today
I came across this recently, up until now I have been happily overriding the
I came across this class while reading a C# book and have some questions.
today I came a across a pretty strange behaviour of an php based application
After getting fine answer to my previous question , I came across another problem.

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.