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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:07:47+00:00 2026-05-26T18:07:47+00:00

Using a single dynamic selector I have no problems: var answer_id = <?php echo

  • 0

Using a single dynamic selector I have no problems:

var answer_id = <?php echo $answer_id; ?>;

$('#a_flag_' + answer_id).click(function(e) {
        e.preventDefault();

         //Ajax etc...

But if I add several dynamic selectors they do not work (ie, no errors on Firebug console, but also no action when clicked):

var answer_id = <?php echo $answer_id; ?>;

$('#a_flag_' + answer_id,'#a_comments_link_' + answer_id,'#a_best_answer_' + answer_id).click(function(e) {
        e.preventDefault();

         //Ajax etc...

Any ideas what I am doing wrong?

  • 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-26T18:07:48+00:00Added an answer on May 26, 2026 at 6:07 pm

    You need the commas inside the quoted constant strings.

    $('#a_flag_' + answer_id + ', #a_comments_link_' + answer_id + ',  #a_best_answer_' + answer_id).click(// ///
    

    What you want to end up with is a string that looks like

    "selector, selector, selector, ..."
    

    so you need to concatenate a bunch of strings with commas.

    Alternatively, you could build up your separate selectors in an array of strings and then “.join()” them with a comma separator (the parameter to “.join()”).

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

Sidebar

Related Questions

I'm generating a dynamic assembly using Reflection.Emit which includes a single class. I have
It looks like #temptables created using dynamic SQL via the EXECUTE string method have
I'm wanting to have a simple duck typing example in C# using dynamic objects.
I have a highly dynamic single page interface where various user events trigger new
I am using git to manage a dynamic website (PHP + MySQL) and I
I try to make dynamic CSS using PHP . Example on font-family $one =
I'm using PHP to create user-agent based dynamic stylesheets with: AddHandler application/x-httpd-php .css And
I have an MVC3 application doing AJAX edit of a grid line using JQUERY
I am using single table inheritance in my rails application, and want to explicitly
I am using Single Table Inheritance for managing different types of projects. Models: class

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.