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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:07:18+00:00 2026-06-01T06:07:18+00:00

Ive got a jquery app that has several grids (jqgrid) in defferent tabs. Below

  • 0

Ive got a jquery app that has several grids (jqgrid) in defferent tabs.
Below ech grid I have a button:

<div id="content1" class="content">
    <table id="grid1" class="myGridClass"></table>
    <input id="ColChooser1"type = "button" value="Choose Columns" class="grid1"></input>
</div>

<div id="content2" class = "content">    
    <table id="grid2" class="myGridClass"></table>
    <input id="ColChooser2"type = "button" value = "Choose Columns" class="grid2"></input>
</div>

Ive got different functions for each of the column chooser buttons: example

$('#ColChooser1').click(function(){
  $('grid1').jqGrid('columnChooser');
};

Whats the best way to write one function for all the buttons?

so far this is what Ive got

$('div.content :input[value="Choose Columns"]').click(function{
   $('div.content table.'+this.attr('class')).jqGrid('columnChooser');
});

not sure if this.attr('class') will always be the same despite each button having the same class as its table element since jquery ui may add additional classes —

Edited
Below is what worked – close to the 1st answer below but tweaked a bit –

            $('div.DataContent :input[value="Choose Columns"]').click(function() {
                $(this).parent().find('.myGridClass').jqGrid('columnChooser');
            });

used .find instead of .children to traverse deeper than 1st level (jqgrid nests the original table element deeper)
also used a more specific selector ‘.myGridClass’ rather than ‘table’ because jqGrid adds several other table elements, making use of the ‘table’ not return the original one intended

  • 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-01T06:07:20+00:00Added an answer on June 1, 2026 at 6:07 am

    Take a look at the traversing page in the jQuery docs. You should be able to use a combination of these functions (e.g. parent, parentsUntil, children) to select the elements you want.

    e.g:

    $('div.content :input[value="Choose Columns"]').click(function{
        $(this).parent().children('table').jqGrid('columnChooser');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a Django app that accepts uploads from jQuery uploadify , a jQ
I've got a Rails 3.2.1 app that I'm trying to include some jquery in.
Ive got a jquery table that allows me to select a record. When that
I've got an Asp.Net mvc web app that has a controller action to handle
I've got a jquery-mobile app with two real html pages, but many more data-role=page
I'm upgrading an app from prototype.js to jquery. I've got this code (prototype.js): var
I have a standard textbox and I've got jQuery on the page. I want
I've got a jquery json request and in that json data I want to
i've got some jquery script that changes element image on mouseover and the problem
I have a single page jQuery Mobile app with four data-role='pages' in place; so,

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.