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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:54:05+00:00 2026-05-23T22:54:05+00:00

HTML: <table border=1px> <tr> <td colspan=2> <div class=commentLink> <a onclick=ShowBox.call(this); return false; href=#>Comment</a> </div>

  • 0

HTML:

<table border="1px">
        <tr>
            <td colspan="2">
                <div class="commentLink">
                    <a onclick="ShowBox.call(this); return false;" href="#">Comment</a>
                </div>
            </td>
        </tr>
        <tr class="commentBox" style="display: none;">
            <td colspan="2">
                <div class="hiddenComment">
                    <textarea class="textComment" rows="2" cols="100"></textarea>
                    <input class="foo" type="checkbox" />
                    <input class="commentBtn" type="button" value="Submit" onclick="addComment.call(this); return false;" />
                    <input class="commentBtn" type="button" value="Cancel" onclick="HideBox.call(this); return false;" />
                </div>
            </td>
        </tr>
    </table>

JS: using jquery 1.4.2

function ShowBox() {
        var that = this;
        $(function () {
            $(".commentBox").show();
            //$(that).closest('tr').siblings().show();
        });
    }
    function HideBox() {
        var that = this;
        $(function () {
            $(that).siblings(".foo").attr("checked", false);
            $(that).siblings(".textComment").empty();
            $(".commentBox").hide();
        });
    }  

I have the two functions to show/hide a tr. The code I have now works, but it will close other elements too. What is the elegant way of doing this?

  • 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-23T22:54:05+00:00Added an answer on May 23, 2026 at 10:54 pm

    This should do it:

    function ShowBox() {
        $(this).closest ('tr').next ('tr.commentBox').show ();
    }
    
    function HideBox() {
        var jThis   = $(this);
    
        jThis.siblings(".foo").attr("checked", false);
        jThis.siblings(".textComment").empty ();
        jThis.closest ('tr.commentBox').hide ();
    } 
    

    BTW, for “elegant”, remove the onclick attributes from the HTML!

    Then add the click functionality with:

    $('td div.commentLink > a').bind ('click', ShowBox, false);
    $('td div.hiddenComment > a.commentBtn[value=Submit]').bind ('click', addComment, false);
    $('td div.hiddenComment > a.commentBtn[value=Cancel]').bind ('click', HideBox, false);
    

    inside the $(document).ready ().

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

Sidebar

Related Questions

I have a HTML table like this: <table border=1> <tbody> <tr> <td><a href=# class=delete>DELETE
I have the following table in my HTML: <div style=max-width:700px;> <table border=1> <tr><td colSpan=2>this
My HTML: <table class=tab> <tr><td>aa</td><td>aa</td><td>aa</td></tr> <tr><td colspan=3><div class=in>bbb</div></td></tr> </table> <table class=tab> <tr><td>aa</td><td>aa</td><td>aa</td></tr> <tr><td colspan=3><div
CSS table tr {border-bottom:1px solid #008999} HTML <table width=100% cellspacing=0 cellpadding=0> <thead> <tr> <th
I have an html table <table border=0 width=100%> <tr class=headerbg> <th width=5%> No </th>
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd> <html> <head> <style> table {border: 1px solid
I want to create a html table with a 1pt black outer border and
I have the following HTML table: <table style=width: 100%;> <tr> <td class=title_bar_left_border></td> <td class=title_bar_middle></td>
I have an HTML table that looks like this: ------------------------------------------------- |Column 1 |Column 2
This HTML table is being misinterpreted by some browsers, and I cannot understand why

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.