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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:57:15+00:00 2026-06-03T22:57:15+00:00

As the title reads, I’d like to pass show() & hide() jQuery functions as

  • 0

As the title reads, I’d like to pass show() & hide() jQuery functions as parameters in another function.

function applyActionOnClass(attr, action) {
    $('#salesonhold_table tr').each(function () {
    if ($(this).attr('status') == attr)
        $(this).action;
    });
}

Here is when I call my applyActionOnClass function:

$(document).on('change', '.checkboxes', function () {
    var attr = $(this).val();
    if ($(this).is(':checked'))
        applyActionOnClass(attr, show());
    else
        applyActionOnClass(attr, hide());
});

To explain a bit the purpose of this, I have a table and each of its <tr> has a status attribute which differs them from each other. I have two checkboxes on top of the table, one for each possible status value and I’d like to hide/show corresponding <tr> when checkboxes are triggered.

The trigger and stuff work fine but when it comes to $(this).action; it says hide is not defined. Any idea what I did wrong there?

Thank you so much !

  • 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-03T22:57:16+00:00Added an answer on June 3, 2026 at 10:57 pm

    You can pass an anonymous function (or delegate) instead. This code handles that:

    function applyActionOnClass(attr, func) {
        $('#salesonhold_table tr').each(function () {
        if ($(this).attr('status') == attr)
            func($(this));
        });
    }
    

    This code passes the delegate in:

    $(document).on('change', '.checkboxes', function () {
        var attr = $(this).val();
        if ($(this).is(':checked'))
            applyActionOnClass(attr, function(e) { e.show(); });
        else
            applyActionOnClass(attr, function(e) { e.hide(); });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

jQuery Code: $(document).ready(function(){ $.getJSON('dat.js', function(data) { var obj = JSON.parse(data); alert(obj[0].title); }); }); My
As the title reads... is this possibly? Workflow should be like: 1.- User is
as the title reads I'd like to find a webpage which presents an overview
as the title reads, I'd like to know what is the most reliable way
As the question title reads, assigning 2^31 to a signed and unsigned 32-bit integer
I have a text title that reads This User The Title Of The Post
I have a program which reads Inbox messages from email accounts, as the title
<HTML> <HEAD> <title>Login</title> <script type=text/javascript src=http://script.auction.co.kr/common/jquery.js></script> <script type=text/javascript> $(document).ready(function() { $(:input[name='txtPassword']).blur(function(e){ $(this).css(background-color,white); }); $(:input[name='txtPassword']).focus(function(e){
Sorry for the confusing title. Basically I made a BinaryReader class that reads in
So, as the title reads I need to update the friendly names of attributes

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.