jQuery this closest show hide

0 votes

I've got a table with multiple rows. In each row is a Show Details Button and a Hide Details button. On clicking show details I want the hide details button to only show for the specific row. I thought the .closest() function would work but it hasn't yet.

Here is the HTML

<table>
    <tr id="1">
      <td><button class='view'>View Details</button><button class='hide' style='display:none;'>Hide Details</button></td>
    </tr>

    <tr id="2">
      <td><button class='view'>View Details</button><button class='hide' style='display:none;'>Hide Details</button></td>
    </tr>
</table>

Here is the jQuery

$(".view").click(function() {   
    $("#patient").show("");
    $(this).hide();
    $(this).closest(".hide").show();
});

Aug 12 in Web Development by gaurav
• 18,960 points
10 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Web Development

0 votes
1 answer

jQuery $(this) selector function and limitations

this isn't a jQuery "thing", but a basic JavaScript ...READ MORE

answered Jun 23 in Web Development by rajatha
• 7,440 points
25 views
0 votes
0 answers

jQuery show for 5 seconds then hide

I'm using .show to display a hidden ...READ MORE

Jul 29 in Web Development by gaurav
• 18,960 points
37 views
0 votes
1 answer

Not able to show/hide div which is nearest to checkbox using JQuery

pretty simple: $('.check-hide-show-content').hide(); // hide all content divs // ...READ MORE

answered Aug 2 in Web Development by rajatha
• 7,440 points
91 views
0 votes
1 answer

JQuery Difference between hide() and fadeOut() , show() and fadeIn()

Main difference between FadeIn, FadeOut vs hide, ...READ MORE

answered Aug 5 in Web Development by rajatha
• 7,440 points
58 views
0 votes
1 answer

$("#select option:second").val() jquery - keep select second value of select box option

Yes, you want the special jQuery eq() selector. ...READ MORE

answered Jun 22 in Web Development by rajatha
• 7,440 points
22 views
0 votes
1 answer

How to hide a div with jQuery?

We hide the divs by adding a CSS ...READ MORE

answered Jun 27 in Web Development by rajatha
• 7,440 points
33 views
0 votes
1 answer

How to use jquery with asp.net ajax?

If you weren't aware, Microsoft is planning ...READ MORE

answered Oct 15, 2018 in IoT (Internet of Things) by Annie97
• 2,160 points
200 views
0 votes
1 answer

Is 'sparkline' a method?

I suggest you to check 2 things That jquery.sparkline.js is actually ...READ MORE

answered Nov 9, 2018 in Apache Spark by Frankie
• 9,830 points
623 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,510 points
322 views
0 votes
1 answer

Error: Global Variable is not accessable to local function

Hey kartik, A variable declared outside a function has a ...READ MORE

answered Feb 19, 2020 in PHP by Niroj
• 82,780 points
297 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP