Solved

How can incorporate this animated show / hide dynamic into this scenario?

Posted on 2015-02-05
3
57 Views
Last Modified: 2015-02-11
This works:

<!doctype html>
<html lang="en">
<head>  
<meta charset="utf-8">  
<title>jQuery UI Effects - Hide Demo</title>  
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>

 
 <style>
.slidingDiv {
    height:300px;
    background-color: #99CCFF;
    padding:20px;
    margin-top:10px;
    border-bottom:5px solid #3399FF;
}
 
.show_hide {
    display:none;
}


</style>
 
 </head>
 
 <body>
 <script type="text/javascript">
 $(document).ready(function(){
 
        $(".slidingDiv").hide();
        $(".show_hide").show();
 
    $('.show_hide').click(function(){
    $(this).next().slideToggle();
    });
	
});
 </script>
 
 <a href="#" class="show_hide">Show/hide</a>
	<div class="slidingDiv">
	Fill this space with really interesting content. 
	</div>
	<br><a href="#" class="show_hide">Show/hide</a>
	<div class="slidingDiv">
	Fill this space with really interesting content. 
	</div>
</body>
</html>

Open in new window


This does not:

<a href="#" class="show_hide">Show/hide</a>
<table>
	<tbody class="slidingDiv">
		<tr>
			<td>hello</td>
			<td>indeed</td>
		</tr>
	</tbody>
	<tr>
		<td>and...</td>
		<td>not really</td>
	</tr>
</table>
	

Open in new window


What I'm trying to do is achieve the same kind of animated motion with the rows of my table that I have with the slidingDiv div in the first example.

In other words, I want a collection of rows hidden until I click a link, at which point I get that smooth transition of them being revealed.

How?

Looking forward to hearing from minds greater than my own!
0
Comment
Question by:brucegust
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Expert Comment

by:Brian Tao
ID: 40592610
The "next()" of your last "show_hide" is the table and not the tbody tag, so it shows/hides the entire table, and doesn't work on the tbody.
0
 

Author Comment

by:brucegust
ID: 40592620
Brian! Sorry to be such a teacup, but could you show me what it's supposed to look like?
0
 
LVL 9

Accepted Solution

by:
Brian Tao earned 500 total points
ID: 40592643
Actually there's no way of "grouping" a set of rows in a table.  To achieve the expected result, you may want to add the class="slidingDiv" to each row that you want to toggle, and modify your code from
$(this).next().slideToggle();

Open in new window

to
$(".slidingDiv").slideToggle();

Open in new window

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question