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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:54:09+00:00 2026-06-07T07:54:09+00:00

Obviously I’m doing something wrong. I’ve never been able to get .click() to work,

  • 0

Obviously I’m doing something wrong. I’ve never been able to get .click() to work, but other jQuery calls work fine.

I have the following Javascript function:

    function showParamsFor(divID) {
       //Code here works when the function is called through onclick attribute
    }

Then, I basically have the following scenario:

    int index = 0;
    foreach (var op in Model.Operations)
    {
       <div id="param_container[@(index)]"
          <a id="show_params[@(index)]" href="#">
             Edit Parameters
          </a>
       </div>
       index++;
    }

    int total = index;
    <script type="text/javascript" src="~/Scripts/jquery-1.6.2.min.js"></script>
    for (int i = 0; i < total; i++)
    {
        <script type="text/javascript">
            $(document).ready($('#show_params[@(i)]').click(function () {
                showParamsFor('#param_container[@(i)]');
            });
        </script>
    }

For the life of me, I can’t seem to get this to work. Aside from .click(), I’ve tried using the following methods:

.live('click', function()) 
.bind('click', function()) 

I’ve tried removing $(document).ready and adding it back in each scenario, but nothing happens when the link is clicked.

I’ve double checked my id names and even tried using a class name for the link (.show_params[@(i)]) instead of the id. Whaat am i doing wrong here?

EDIT

I’m using a loop because I have a dynamic list of these links. I need to bind a click event to each after they have ALL been created because each link needs a reference to each of the other links.

  • 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-07T07:54:11+00:00Added an answer on June 7, 2026 at 7:54 am

    Thanks for the responses, but I’ve figured out my problem.

    1. I was passing ‘#param_container[@(i)]’ into my showParamsFor function when I should have been passing ‘param_container[@(i)]’ into it. No hash tag.

    2. A more impotant problem… The brackets in my id’s weren’t being recognized by jQuery. I read that you can use \\ as an escape characer before the brackets, but naturally.. that didn’t work for me. I changed my id’s from ‘param_container[@(i)]’ to ‘param_container-@(i)’.

    Everything seems to be fine. Here’s my final script:

        <script type="text/javascript" src="~/Scripts/jquery-1.6.2.min.js"></script>
        <script type="text/javascript">
            for (var i = 0; i < total; i++)
            {
                $(document).ready(function() {
                   $('#show_params-'+i).live('click', function (data) {
                        showParamsFor('param_container-'+i);
                    });
                });
            }
        </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So obviously I am doing something wrong, but I just cannot seem to get
Obviously, there must be something stupid i'm doing. The unicode chart for subscripts and
Obviously both have their benefits. MyISAM is fast but may get currupted easily, InnoDB
Obviously I can do and DateTime.Now.After - DateTime.Now.Before but there must be something more
height: 100% in CSS obviously doesn't work. So is there any other CSS or
Obviously there must have been a programming language to write a compiler for, but
Obviously I have my own opinion and way of doing this, but I would
Obviously best-case is O(n), but apparently the worst-case is O(n 2 ), which I
Obviously ||= won't work def x? @x_query ||= expensive_way_to_calculate_x end because if it turns
Obviously, the typical WebForms approach won't work. How does one track a user in

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.