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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:18:12+00:00 2026-05-14T04:18:12+00:00

I have the following snippet of code (I’m using jQuery 1.4.2): $.post(‘/Ads/GetAdStatsRow/’, { ‘ad_id’:

  • 0

I have the following snippet of code (I’m using jQuery 1.4.2):

$.post('/Ads/GetAdStatsRow/', { 'ad_id': id }, function(result) {
    $('#edit_ads_form tbody').prepend(result);
    $(result).find('td.select-ad input').attr('checked','checked').click();
});

Assume that the post works correctly and returns a correct pre-built <tr> with some <td>s. Here’s the weirdness: the $(result).find() line finds the correct input (which is a checkbox, as it’s the only input in the cell) and runs the chained click() function correctly, but it REFUSES to set the box as checked, which I need to happen.

Here’s a crazy twist, too… when I get super specific and change the $(result).find() line to this (the id of the checkbox):

$('#ad_' + id).click();

It checks the box, but doesn’t run the click() function! If I set it to

$('#ad_' + id).attr('checked','checked').click();

it runs the click function as though the box were checked, but the box remains unchecked, and if I do

$('#ad_' + id).click().attr('checked','checked');

it does nothing at all.

What in the world could be the matter with this? I’m running out of hair….

Thanks!

EDIT

Here’s how I set my click event in the $(function()) call:

$('td.select-ad input').live('click',AdPreview.selectAd);

It works as is for all the other checkboxes, and the newly-added checkbox does indeed work if clicked by hand.

EDIT 2

After some digging I discovered that this:

$('#ad_' + id).click();

actually does call my click function in addition to checking the box. However, when the click function is called (I’ve already checked to make sure that input is the correct checkbox and it is),

var input = $(this);
console.log(input.is(':checked'));

the log returns false, even though the box is actually checked! GAH WTF

  • 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-14T04:18:13+00:00Added an answer on May 14, 2026 at 4:18 am

    I figured it out, thank you to all who put me on the right track. Here’s what I had to do:

    First, rather than wiring my checkboxes to run on click(), I updated them to run on change(). After I did this, I used the following line in place of the other:

    $('#ad_' + id).click().change();
    

    and everything works now! The checkbox stays checked and the correct function is called.

    Thanks again everyone!

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

Sidebar

Related Questions

I have the following snippet of code that loops through the jQuery animate function
I have the following code snippet: using (SPSite site = new SPSite(this.ListAddress)) { using
I have the following code snippet function receiver(callback) { console.log( callback ); } function
I have the following code snippet. $(#days).keypress(function(e){ if(e.keyCode == 13){ self.validateNightModalForm(); } }); basically,
I have the following snippet of code. abstract class MrParent { public function __construct()
I have following code snippet: self.xmlHttpReq = new XMLHttpRequest(); self.xmlHttpReq.onreadystatechange = function() { if(self.xmlHttpReq.readyState
I have following code snippet: var reg = /^[0-9]$/; $('input[type=text]').keypress(function(){ console.log(reg.test(parseInt($(this).val()))); }); When I
I have following code snippet in jquery.In which,I want to animate each element of
I have the following code snippet in my page. <script type=text/javascript> function expandCollapse(id){ var
I have the following code snippet: Action<IProbingErrorHandler> handlerAction = x => x.Post(sourceContext, channelId, probingError);

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.