Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now