Solved

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

Posted on 2015-02-05
3
55 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
  • 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

832 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