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

  • Home
  • SEARCH
  • 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 6782017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:41:30+00:00 2026-05-26T16:41:30+00:00

I have a jquery function whichh looks like this: <script type=text/javascript> $(document).ready(function() { $(‘a#id’).click(function(e){

  • 0

I have a jquery function whichh looks like this:

<script type="text/javascript">
$(document).ready(function() {
    $('a#id').click(function(e){
        e.preventDefault();
        var id = $(this).attr('pid');
        var title = $(this).attr('ptitle');
    $('#product_list').prepend('<input type="hidden" value="'+ id +'"/><div>'+ title +'</div>')
    });
});
</script>

I have a javascript file which has this code here:

> http.open('get', 'livesearch.php?name='+searchq+'&nocache =
> '+nocache+'&type=bookings/products');

The livesearch.php file has the a element (which the jQuery is requesting) like this:

<a href="#" id="id" ptitle="<?php echo $product['title']; ?>" pid="<?php echo $product['product_id']; ?>">Add</a>

However when I click on the a element the jQuery doesn’t respond. Could any please help?

Thanks
Peter

  • 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-26T16:41:30+00:00Added an answer on May 26, 2026 at 4:41 pm

    Use either live or delegate to add the click event because the element is not present in the DOM at the time the event is bound.

    $('#id').live('click', function(e){
            alert('you clicked the id element' ); 
    });  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jQuery which I need adapting: $(document).ready(function(){ $(.rss-popup a).hover(function() { $(this).next(em).stop(true,
I have some jQuery that looks like this: $.ajax({ type: POST, url: /Customer/CancelSubscription/<%= Model.Customer.Id
I have a every common page a.html which looks like this: <html> <head> <script
I have this jQuery which works fine $(li[id^='shop_id']).click( function () { alert(I clicked on
We have this anonymous function in our code, which is part of the jQuery's
Here's the story... I have a jQuery function that does something, this function is
I have followed this tutorial which uses jQuery UI to generate Facebook tokens like:
I am using jQuery.load() to render a partial view. This part looks like this:
a) I have an html page that looks like this: <html> <head> <title>Page Title</title>
I have a link that looks like this: <p class=half_text> <?php echo $upvotes; ?>

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.