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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:56:29+00:00 2026-06-05T06:56:29+00:00

Basically this is my function: function FillDivLeft(groups, side) { var cnt = 1; $.each(groups,

  • 0

Basically this is my function:

function FillDivLeft(groups, side) {
 var cnt = 1;
 $.each(groups, function (index, groups) {
     $(side)
     .append(
         $(document.createElement('label')).attr({
             id: cnt + 'lbl',
             class: 'myClass'
         })
     );
     $('#' + cnt + 'lbl')
     .append(
         $(document.createElement('input')).attr({
             id: groups.GroupCode,
             type: 'checkbox',
             name: 'testGroup',
             class: 'leftClass'
         })
     );
     $('#' + groups.GroupCode).after
     (
         $(document.createElement('span')).text(groups.GroupName).attr({
             class: 'leftSpan'
         })
     );
     $('#' + cnt + 'lbl').after($(document.createElement('br')));
     cnt = cnt + 1;
 }); 
}

I have tried all sorts and although the new elements are created, classes assigned etc. it appears that all jquery functions on the page do not work, such as:

$('.leftSpan').click(function () {
    $('#lblOutput').text(this.id);
});

Even a hover function on the parent div does not work.

I can’t see a possible cause so any help or pointers would be appreciated.

  • 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-05T06:56:31+00:00Added an answer on June 5, 2026 at 6:56 am

    You need to use ‘on’ if you are using jQuery 1.7+. You can replace ‘body’ with any parent div of the element

    $('body').on('click','.leftSpan',(function () {
        $('#lblOutput').text(this.id);
    });
    

    Using just the .click function requires the elements to be created when the dom is ready. It will not attach the event to elements created dynamically. If you are using jQuery 1.6 and below you will have to use the .live instead

    You can read more about ‘on’ here http://api.jquery.com/on/

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

Sidebar

Related Questions

$('input[class*=defaulttext]').each(function () { this.value = $(this).attr('title'); $(this).addClass('defaultclass'); $(this).focus(function () { if (this.value == $(this).attr('title'))
I've got some R code that looks basically like this: compute.quantiles <- function(mu, type)
is this ok? im basically replacing a call to a single function referencing globals,
So I have a log table. Rows are basically like this: id function n
I am making a function (PHP). In this function it basically uses the dbms
Hey all. Basically, I need (this) in my function to correspond to this selection:
What's the shortest way (characters) of creating a new function alias. Basically this is
Basically this function is meant to store the height value of the element that
I've made a general hash up of the following function. Basically linking this function
basically i have this click function in jquery: (this is just a snippet, not

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.