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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:57:38+00:00 2026-06-16T15:57:38+00:00

I have this bit of jQuery (excuse the horrible html appends – these will

  • 0

I have this bit of jQuery (excuse the horrible html appends – these will be eventually shortened!)

$(function () {
  $(".follow").click(function () {
    var element = $(this);
    var I = element.data("userid");
    var info = 'id=' + I;
    var Something = $('#latestbettors tr[data-userid=' + I + ']').find('td:eq(0)').text();

    $.ajax({
      type: "POST",
      url: "follow.php",
      data: info,
      success: function () {
        $('.follow[data-userid=' + I + ']').fadeOut(200).hide();
        $('.following[data-userid=' + I + ']').fadeIn(200).show();
        if ($('#yourfollowers table tr > td:contains("You arent currently following any bettors")')) {
          $('#yourfollowers table tr:contains("You aren\'t currently following any bettors")').remove();
        }
        if ($('#yourfollowers tr:contains("' + I + '")') && $('#yourfollowers tr > td:contains("' + Something + '")').length < 1) $('#yourfollowers table').fadeIn(200).append("<tr data-userid='" + I + "'><td>" + Something + "</td><td><a href='#'data-userid='" + I + "' class='following'></a><a href='#' data-userid='" + I + "' class='follow' style='display:none'></a></td></tr>");
      }
    });
    return false;
  });
});

$(function () {
  $(".following").click(function () {
    var element = $(this);
    var J = element.data("userid");
    var infos = 'id=' + J;

    $.ajax({
      type: "POST",
      url: "unfollow.php",
      data: infos,
      success: function () {
        $('.following[data-userid=' + J + ']').fadeOut(200).hide();
        $('.follow[data-userid=' + J + ']').fadeIn(200).show();
        $('#yourfollowers tr[data-userid=' + J + ']').fadeOut(200).remove();

        if ($('#yourfollowers table tr').length == 0) {
          $('#yourfollowers table').append('<tr><td>You aren\'t currently following any bettors</td></tr>');
        }
      }
    });
    return false;
  });
});

I have two tables – latest bettors and following. The latest bettors table includes all of the newly signed up users with a follow button beside each (or following if the user is following them) … The following table includes all of the users the user is following with a following button beside each.

When the user clicks the follow button in the ‘latest bettors’ table it appends the user they have followed to the ‘following table’ – this works well. However when the user clicks on the ‘following’ button after this in the ‘following’ table – nothing happens? Why is this?

  • 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-16T15:57:40+00:00Added an answer on June 16, 2026 at 3:57 pm

    For dynamically generated elements, event should be delegated from one of static parents of the element or document object, you can use on or delegate method:

    $(document).on('click', '.following', function(){
    

    If you are using jQuery below 1.7 version you can also use delegate method:

    $(document).delegate('.following', 'click', function(){    
    

    Updated by @Exception:

    And also you can use

    $('.following').live('click', function(){    
    

    But live is deprecated in latest versions of jQuery. It may work now if you are using old jQuery version, but it may not work with latest version of jQuery you use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problems with the following bit of javascript/jquery code: this.droppable = function(){ $('.imageWindow
I have this bit jQuery with HTML. Unfortunately its not working correctly. Can anyone
I have this bit of jQuery: $('body').bind('orientationchange',function(event){ alert('orientationchange'); }) If you change the orientation
I am trying to improve my jQuery skill and I have this bit of
So I have been dabbling around in jQuery a bit this week. Trying to
I have this bit of JavaScript... 15 $('.ajax_edit_address').each(function() { 16 $(this).ajaxForm({ 17 target: $(this).parents('table.address').find('tr.address_header').children(':first'),
I have this small snippet to change a bit of html when a user
I have this jquery code: $(.button-banc).hover(function() { $(.button-banc img) .animate({ top: -21px }, 200).animate({
I'm using Cargo Collective to host http://cargocollective.com/amytdatta/biography I have this bit of jQuery in
I have written this simple bit of jQuery that swaps out the containing ul's

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.